arrays - Storing vectors and matrices of different sizes in loops -


i want store values of different matrix/vector sizes each loop algorithm performing. mwe follows:

for n1=1:t  a1=f1(n1)  % expression depends on n1             % a1 parameter value n2=1:t   a2=f2(n2)   % expression depends on n2               % a2 parameter value       while d<1       algorithm=f(a1,a2,)  % algorithm depends on these parameter values     end        % in step want remember combination of parameters , store  results        v1= [a1 a2]  % store combination of parameters used in while loop        [a,b,c]=somefunction() % results given inputs while loop       % a,b,c matrices **of different sizes**        v2 = [ 4x1 4x1 4x1]   % store column vectors      % want      % remember , see in matlab convenient form following:     % 1. combination of parameters in v1      % 2. got b c matrices , matrix v2     end end 

can 1 me how can efficiently possible ? ideally want store names of of parameter values , matrices every time loop executed, don;t know whether possible in matlab.

consider using dynamic field references in structure. allow create ouput structure, results , inputs given run in loop. adapting idea code.

for n2=1:maxruns %  same code above.        algorithmoutput.((strcat('run',int2str(n2))).input.a1=a1      algorithmoutput.((strcat('run',int2str(n2))).input.a2=a2      % store inputs in algorithmoutput.run1.input      algorithmoutput.((strcat('run',int2str(n2))).output.v1=v1;      algorithmoutput.((strcat('run',int2str(n2))).output.v2=v2;      % store inputs in algorithmoutput.run1.output   end 

things note here, need make sure start dynamic reference letter , not number (matlab naming rules). need use fields(alogrithmoutput) return cell array in case of runs can subsequently iterate over. while cause issues if have deep , complex inputs , outputs, should allow intuitive way access inputs/outputs of given run through syntax such alogrithmoutput.run5.input.a1 etc.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -