Calling multiple matlab scripts in to single script?

29 visualizaciones (últimos 30 días)
sam moor
sam moor el 20 de En. de 2017
Respondida: Sparsh Jain el 31 de En. de 2019
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 comentario
Adam
Adam el 20 de En. de 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.

Iniciar sesión para comentar.

Respuestas (3)

the cyclist
the cyclist el 20 de En. de 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.
  1 comentario
sam moor
sam moor el 20 de En. de 2017
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.

Iniciar sesión para comentar.


Stephen23
Stephen23 el 20 de En. de 2017
Editada: Stephen23 el 20 de En. de 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.

Sparsh Jain
Sparsh Jain el 31 de En. de 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.

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by