Is it Possible to store an if Condition in a String to manipulate later ?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Am I able to do something like this in Matlab? Please advice
aaa = 'r > 0 && r < 5 '; if (aaa) r = r+1; end
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Guillaume
am 22 Okt. 2014
Bearbeitet: Guillaume
am 22 Okt. 2014
If you really want to store your condition in a string, then use eval as Orion said. However, I wouldn't do that as you don't get an syntax check for the code in your string.
aaa = @(x) x>0 && x<5; %anonymous function, the name of the variable doesn't matter
if aaa(r) r=r+1;
0 Kommentare
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!