How to have user input for a m-file with in a separate script?

6 views (last 30 days)
Hello, I am fairly new to MATLAB and was wondering what commands i need to have a user input the name of a m-file within a separate script. I need the user to specify the name and have the main script search and subsequently launch the user specified scrip. This main script is basically a Gui interface. My code looks as follows: -----
if true
cinit %sets path of the location of separate m-files
who
%following sets main variables
cdata= input('cdata= ');
time= input('time= ');
cdata(1,:)=time;
%searching for the user specified fit
fit= input('what is the name of the fit you would like?: ','s');
if strcmpi(fit,'expfit2')
expfit2 %example of a custom fit in my path
end
end
The problem that I am having is that I have hundreds of possible custom fits in my path that I would like to be able to be to look up, and writing an if/else statements does not seem like the best approach.

Answers (1)

Christian
Christian on 11 Oct 2013
Edited: Christian on 11 Oct 2013
Figured it out, I just need to have the command
if true
*run(fit)*
end
which searches for the string specified in the var, fit.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!