# Combine 3 fig. graphs in one plot to compare each other

4 views (last 30 days)
Saba Hajhassan on 23 Mar 2023
Edited: Saba Hajhassan on 24 Mar 2023
Hi, I have three graphs from 3 differnet simulation which represent different resutls. I wanna combine them together in plot, and I have tried differnet ways, but unfortunately I was not successful, I upload these three graphs as screenshots, because they exceed the 5MG limit.
And I appreiciate it if anyone could help me with this problem.
Thanks and have a good day!

Matt J on 23 Mar 2023
Edited: Matt J on 23 Mar 2023
Suppose ax is a vector of axes handles to all of your separate plots. Then, you could re-parent the axes to a TiledChartLayout in a new figure,
N=numel(ax);
figure;
T=tiledlayout(N,1);
set(ax,'Parent',T);
for i=1:N
T.Children(i).Layout.Tile=i;
end
Saba Hajhassan on 23 Mar 2023
Edited: Saba Hajhassan on 24 Mar 2023
Thank you very much, I really do appreciate it. Yes the second plot was the idea. But the only problem is, if you look at the screenshots that I have uploaded, you will see that the x-axis is a time axis and its the simulation time of 7 seconds but here is something else. Do you know how I can solve this?
One last thing, do you know how I can label the them so I can recognize which graph is for Gain 23 and which one is for Gain 25 and so on?

Jon on 23 Mar 2023
You should run each of the simulations keeping the results in local variables stored in the base workspace, and then plot the data using these variables. So for example suppose the results of running the first simulation were kept in the variable t1,x1 the second simulation in t2,x2, and for the third t3,x3 then you could plot the combined results using
plot(t1,x1,t2,x2,t3,x3)
Saba Hajhassan on 23 Mar 2023
Thanks for your comment, yes i have saved them as array to the workspace and here I uploded them. I am still not able to combine all the three graphs in one. Could you please help me with that? I really appreciate it.

### Categories

Find more on Formatting and Annotation in Help Center and File Exchange

R2021b

### Community Treasure Hunt

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

Start Hunting!