Variable interpolation
Variable interpolation
(OP)
I would like to know how to name new variables using the value of a current variable. In my case, I get some user input, then want to create variables using the user's input as a suffix.
rpm = input('Speed in RPM: ');
test_rpm = 2;
So, if the user entered 1000, I want the next variable to be named test_1000. I love being able to do this in Perl, and I hope it can be done in Matlab.
Thanks for the help.
rpm = input('Speed in RPM: ');
test_rpm = 2;
So, if the user entered 1000, I want the next variable to be named test_1000. I love being able to do this in Perl, and I hope it can be done in Matlab.
Thanks for the help.





RE: Variable interpolation
M
--
Dr Michael F Platten
RE: Variable interpolation
try
eval( [ 'test_', int2str( round( rpm ) ), ' = ', int2str( round( rpm ) ) ] )