MATLAB: Automatic building of an array

anti-patterndynamically named variablesMATLABnaming the array with different names automatically

Hey all,
Below is my function. I need to build the array automatically for the user input.
function suri1(Measuring_Data(:,7))
%User input
X = {1, 2,'Node1'; 3, 4, 'Node2'; 5, 6, 'Node3'}; % different for different users
n = 10;
d_T= 1 ;
t = 200;
S = load('Measuring_Data.mat');
f = 0:d_T:(t-1)*d_T;
p = cell2mat(X(:,1));
q = cell2mat(X(:,2));
disp(p);
disp(q);
T_Vorgabe = zeros(1,length(f)); % Row vector
for plotnumber = 1:n
c = find(p == plotnumber,1);
if ~isempty(c)
c = plotnumber;
for plotnumber1 = 1:n
c1 = find(q == plotnumber1,1);
if ~isempty(c1)
c1 = plotnumber1;
T_Vorgabe{c}(1,:) = S(c1,1); % May be worng syntax , All the values of the measuring data should be copied to T_Vorgabe as a row %vector or row cell array, c is the user input number to build the vector or cell array of different names
end
end
end
end
figure
hold('on')
for plotnumber2 = 1:n
c2 = find(p == plotnumber,1)
if ~isempty(c2)
c2 = plotnumber;
plot(f(1:15:end)/200, T_Vorgabe{c2}); % Slover should plot all the values of T_Vorgabe(row vector or row cell array.
end
end
end
Here T_Vorgabe{c2} will be cell array. Now while plotting the T_Vorgabe solver should get the all the values stored from the respective cell arrayT_Vorgabe{c2}.
My questions are,
How to make T_Vorgabe as a row vector, or row cell array of different names according to user input?
Like below
T_Vorgabe{1}=[1,2,3,,2920]
T_Vorgabe{2}=[2921,2922,2923,,5840] etc
Any suggestions and answers are most welcomed.
Thanks in advance

Best Answer

'T_Vorgabe{c}(1,:) = S(c1,1);
I just need to know whether it is correct or not!. '
As I mentioned before, the concept is sound, and it should produce something like what you are looking for. I cannot tell you if it is 'correct' because minor adjustments may be needed to personalize the code to your specific dataset. I suspect this line will not actually have to be changed, but perhaps your definition of c and c1 will need to be changed. That is something you will have to tackle though when you have an actual sample of data to work with. That's just how debugging works.
'Second question is How to access the indicies of element of cell array?'
For information on how to work with cell indices I recommend this link. If you still need additional help, please be more specific.