MATLAB Answers

How do I use two different matlab scripts to plot the figure using subplot?

32 views (last 30 days)
sam moor
sam moor on 9 Feb 2017
Commented: Gayan Lankeshwara on 18 May 2020
I have two different matlab scripts that works on different directory which plots the different figures from each script. I don't have any function on both scripts. What I want to do is say I plot first figure from first matlab script than I want to plot next figure from second figure side by side (like subplot function) and so on. Is there any idea we can do like this? let me know any suggestions.

Answers (1)

Star Strider
Star Strider on 9 Feb 2017
Try this:
plot(1:10, rand(1,10), '-b');
hax1 = gca;
plot(1:20, rand(1,20), '-pr');
hax2 = gca;
f3 = figure(3)
The figure(3) object will have the plots from the first two figures as subplots. See the documentation for subplot for a full explanation and additional options.
Note that your functions will have to return the axes handles (here ‘hax1’ and ‘hax2’) as outputs so you can use them in the subplots.
Experiment with your code to get the result you want.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by