Calling multiple matlab scripts in to single script?
29 views (last 30 days)
Show older comments
Let's say I have four matlab files named a.m, b.m, c.m and d.m. In every matlab file, there is figure to plot. I want to introduce a new matlab script and call all these four matlab files and like to see all the plot of the each script at one time? Is it possible to do? If so what function do I need to use?
1 Comment
Adam
on 20 Jan 2017
I would strongly recommend using functions instead of scripts. Unless all your scripts use different variables or are happy to override all the previous ones running 4 scripts in turn is a recipe for a cluttered workspace or lots of bugs with variables overwritten or things from the previous script cluttering the next script.
Answers (3)
the cyclist
on 20 Jan 2017
You can call a script from inside another script by simply typing the name (without the .m extension), so if you make an M-file named singleFile.m, and that file contains the lines
a
b
c
d
I believe it should do what you want.
Stephen23
on 20 Jan 2017
Edited: Stephen23
on 20 Jan 2017
"Is it possible to do"
We don't know this unless you give us more information. Do you call figure in those scripts? Do you call hold anywhere? Have you written close or any other relevant graphics commands?
If you simply have one plot or the like in each script then you could try this:
hold off
a()
hold on
b()
c()
d()
I suspect that the best solution would be to turn all of those scripts into functions with output arguments, then call them from a script and simply plot those outputs all at once. Really scripts are awful things to work with when you have more than one of them. Functions are much better.
0 Comments
Sparsh Jain
on 31 Jan 2019
Hi !
To implement this you need to do the following:
figure (1)
a
figure (2)
b
figure (3)
c
figure (4)
d
This opens up four different figures in separate windows at the same time.
To open all four figures in the same window, you can try playing around with this:
I have not tried it out myself.
0 Comments
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!