Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross 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
Jul 12, 2005
1
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.
 
Replies continue below

Recommended for you

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