Combine 3 fig. graphs in one plot to compare each other
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Saba Hajhassan
le 23 Mar 2023
Modifié(e) : Saba Hajhassan
le 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!
0 commentaires
Réponse acceptée
Matt J
le 23 Mar 2023
Modifié(e) : Matt J
le 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
3 commentaires
Matt J
le 23 Mar 2023
Modifié(e) : Matt J
le 23 Mar 2023
If you have your data as separate arrays, you can just plot them in a single figure in a very basic way using tiledlayout
load matlab.mat
tiledlayout(3,1);
nexttile; plot(K_23);
nexttile; plot(K_25);
nexttile; plot(K_28);
If the idea is to have them all on the same plot, you can instead fo
figure
plot(K_23); hold on
plot(K_25);
plot(K_28); hold off
Plus de réponses (1)
Jon
le 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)
3 commentaires
Jon
le 23 Mar 2023
You could also consider keeping the results in arrays rather than naming them t1,x1, t2,x2 etc
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!