Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations JAE on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable interpolation

Status
Not open for further replies.

DaPuff

Mechanical
Joined
Jul 12, 2005
Messages
1
Location
US
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.
 
Look at the documentation for the "eval" function.

M

--
Dr Michael F Platten
 
MikeyP is correct, eval will do it.
try
eval( [ 'test_', int2str( round( rpm ) ), ' = ', int2str( round( rpm ) ) ] )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top