Assigning a script to a variable
Afficher commentaires plus anciens
Hello,
I have a program that uses input data generated by a script file. There are several different script files that I can use. I want to assign the script to a variable so I can call it in my program.
A simplified version of what I have right now is:
system=input('Which data set is being used?\n');
if system==1
DTSsys_Ieee_rvc;
elseif system==2
Pf4busHw_Ieeerv;
end
This works, but I end up calling these scripts several times in my program, and I have more than 2 systems. So I have these long if-else statements several times in my program whenever I want to reinitialize my input data. Is it possible to shorten my code with something like:
system=input('Which data set is being used?\n');
if system==1
inputData=DTSsys_Ieee_rvc;
elseif system==2
inputData=Pf4busHw_Ieeerv;
end
So that I can just call 'inputData' whenever I need to reinitialize my inputData?
Thanks for the help
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!