Two 'eval' statements in a single command?

3 Ansichten (letzte 30 Tage)
Kyriacos Lambrias
Kyriacos Lambrias am 11 Feb. 2011
Helo everyone, I am trying to creat a loop that does the following: for j=1:13 ; for i=1:I ; var_j(i:) = simulation_i(j,:) end end
Now, in order to achieve this I obviously need to use the command eval, however I need to do so in both the left and the right hand side of my equation above. I tried many things, including: eval(['var',num2str(j),'(i,:) =' eval(['simulation',num2str(i),'(j,:)'])']);
but it does not work. I get a dimensionality problem, in particular on the lines of the marix: ??? Error using ==> horzcat CAT arguments dimensions are not consistent.
Any ideas? I really think it comes from misuse of the eval-statement twice in a single command. Thanks in advance!
Kyriacos

Akzeptierte Antwort

Vieniava
Vieniava am 11 Feb. 2011
This should satisfy your need:
for j=1:13
for i=1:4
eval(['var',num2str(j),'(i,:)=simulation',num2str(i),'(j,:);']);
end
end

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by