Given:
dataCell = {...
'P' 'El' 'Ge' 'R' 'M' 'RANGE'; ...
'A' 'El' 'Ge' 'T' 'M' 'RANGE'; ...
'B' 'El' 'Ge' 'K' 'M' 'RANGE'; ...
'D' 'El' 'Ge' 'M' 'NM' 'RANGE'};
Use a loop looks like this:
for ix = 1:size(dataCell ,1)
curFieldName = dataCell{ix, 1};
curData = dataCell(ix, 2:end); %You can put other data here
data.(curFieldName) = curData; %Note the ".()' notation
end
This leverages a weird syntax feature in Matlab, which is used to reference a field whose name is stored in a variable. Example below
%If you know the name of a field when you are writing the code,
%use this syntax
someStructure.field1 = 1;
%If you want the name of the filed to be generated dynamically, when
%the code is executed, use this syntax (note parenthesis).
theFieldNameInAVariable = 'field1';
someStructure.(theFieldNameInAVariable ) = 1
That results in the structure data
, which looks like this:
>> data
data =
P: {'El' 'Ge' 'R' 'M' 'RANGE'}
A: {'El' 'Ge' 'T' 'M' 'RANGE'}
B: {'El' 'Ge' 'K' 'M' 'RANGE'}
D: {'El' 'Ge' 'M' 'NM' 'RANGE'}
This is the "Use a structure" option as described here: stackoverflow.com/q/15438464/931379. There are at least four good options in the top answers to that question (plus a description of how to do this with variable names.)
Bottom line, there are a lot of ways to store named data in Matlab. Using a structure, like this, is a pretty decent one for many purposes.