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
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
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.
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.
0 个评论
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!