I have a cellarray
whose values are used to initialize corresponding structs.
cellarr = {'NI' ; 'EQ' ; 'TA' } ;
defstr = struct('Raw', '-1') ;
for i = 1:size(cellarr,1)
eval([cellarr{i,1} '= defstr;']) %Yes,I know eval is bad!Any other approach?
end
New values are then filled into the Raw
field.
dataCell = [] ;
for i=1:size(cellarr,1)
rawCell = [cellarr{i} '.Raw'] ;
dataCell = strcat(dataCell, ', ', rawCell) ;
end
dataCell(1) = [] ;
DESIRED STATEMENT NOW --> [NI.Raw,Eq.Raw,TA.Raw] = filldata()
function[a1,a2,a3] = filldata(), a1 = 1 ; a2 = 2 ; a3 = 3 ; end
I am not able to execute the desired statement
, even by using eval
. Shall appreciate your help. filldata
output count would match that of LHS of desired statement
. Thanks.