Calling multiple matlab scripts in to single script?
조회 수: 29 (최근 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!