The best option is to use table() (or dataset() if your Matlab version is older than 2014a but you have the Statistics toolbox):
Order = table({'Order 1';'Order 2';'Order 3'},...
{'Trident';'Hershey';'Kitkat'},...
[2; 3; 6],...
[735887; 735875; 735890],...
'VariableNames',{'Name','Item','Quantity','DueDate'})
Order =
Name Item Quantity DueDate
_________ _________ ________ _______
'Order 1' 'Trident' 2 735887
'Order 2' 'Hershey' 3 735875
'Order 3' 'Kitkat' 6 735890
You can access it as you would do with a structure but you have more advantages, e.g. accessing and inspecting data is easier, smaller memory footprint etc..
What you are trying to build 'manually' is a structure array (and let me stress the array here):
% A structure array
s = struct('Name', {'Order 1';'Order 2';'Order 3'},...
'Item', {'Trident';'Hershey';'Kitkat'},...
'Quantity', {2; 3; 6},...
'DueDate', {735887; 735875; 735890});
s =
3x1 struct array with fields:
Name
Item
Quantity
DueDate
Each scalar structure (/unit/record/object/member call it how you like) of the array will have a set of properties:
s(1)
ans =
Name: 'Order 1'
Item: 'Trident'
Quantity: 2
DueDate: 735887
The organization of the data looks intuitive. However, if you want to apply operations across the whole array, e.g. select those which have Quantity > 2, you need to first concatenate the whole field into a temporary array and only then apply your operation, and in the worst case scenario (if you nest the fields) you will have to loop.
I do personally prefer a database/dataset/table approach where each record is a row and columns are the properties. You can do this by flattening the structure array into a scalar structure (pay attention to the braces):
% A flat structure
s = struct('Name', {{'Order 1';'Order 2';'Order 3'}},...
'Item', {{'Trident';'Hershey';'Kitkat'}},...
'Quantity', [2; 3; 6],...
'DueDate', [735887; 735875; 735890]);
s =
Name: {3x1 cell}
Item: {3x1 cell}
Quantity: [3x1 double]
DueDate: [3x1 double]
Even though the data organization does't appear as intuitive as previously, you will be able to index directly into the structure (and will have lower memory footprint).