I have a kinda specific problem here:
I have a structure with 120 variables, each variable with varying number of rows (but fixed number of columns = 7)
I need to create a new array of the first 2 columns from all the arrays.
The problem I am having is appending the new set of numbers below the first.
Is there a way to do this without eval?
I was trying something like this:
varr = fieldnames(sctData);
for ii = 1:size(sctData,1)
m = 1;
for m = m:m+eval(['size(sctData.' varr{ii} ',1)'])
eval(['sctData2(m,1) = sctData.' varr{ii} '(m,1);']);
eval(['sctData2(m,2) = sctData.' varr{ii} '(m,2);']);
end
end
But ofcourse, this rewrites the variables over the old one. And I really don't want to use eval!
Any help is welcome. :) Thanks!
sctData.(var{ii}). This can be used both for accessing and assigning values - and should hopefully solve your problem.