MATLAB: How to execute script based on input data gotten from another script
functionscript
Hello! I have two scripts, and I want to execute the second one based on data gotten from the first one. How do I do this?
Regards, Sergey
Best Answer
Assuming you don’t want to turn the second one into a function and pass data to it as arguments, the easiest way would be tosave your data to a.mat file in your first script, thenload it in your second script.
Theload function reads your variables from the.mat file and puts them directly in your workspace just as you saved them originally. If you do not want those same variable names in the workspace of your second function (because they would overwrite existing variables with the same names), useload with an output argument. That way you can give the variables in the.mat file specific different names in the second script if you need to.
You wrote awhile condition that will never be true. Have a look at this line:
while n <= n-2
For what values ofn can this be true? Can you think ofany real value ofn where it is less than or equal to itself minus two? Try some real number examples, if you are not sure what is going on, e.g.:
Best Answer