getting an error: this statement is incomplete
Ältere Kommentare anzeigen
Ive been getting this error for the 'eval' line and i'm not sure in what way the statement is incomplete.
% Giving initial values vector (element for each layer) of each state variable.
for i=1:length(R(idR).St.StNames),
eval(strcat('R.St.', char(R(idR).St.StNames(i,:)),' = ', char(R(idR).StM(i,:))));
end
Akzeptierte Antwort
Weitere Antworten (1)
John D'Errico
am 22 Jul. 2017
0 Stimmen
A textbook reason why it is a bad idea to create variable names on the fly. It creates code that is nasty to debug. The code will be slow, and it will be ugly unreadable stuff like this.
If you will write godawful stuff like this, then you need to learn to debug your code.
In the debugger, step in to see what those variables contain at that point. You will probably find that the line you are trying to execute (as it was created) is not correct MATLAB syntax.
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!