Calling multiple matlab scripts in to single script?

27 次查看(过去 30 天)
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 个评论
Adam
Adam 2017-1-20
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.

请先登录,再进行评论。

回答(3 个)

the cyclist
the cyclist 2017-1-20
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.
  1 个评论
sam moor
sam moor 2017-1-20
I get that, But how to plot the four figure of each matlab script in to single window using sub plot. I need to see all figure of all matlab script in same window frame like as we do using sub plot function.

请先登录,再进行评论。


Stephen23
Stephen23 2017-1-20
编辑:Stephen23 2017-1-20
"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.

Sparsh Jain
Sparsh Jain 2019-1-31
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.

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by