Plotting 2D line variable categories

1 vue (au cours des 30 derniers jours)
Zakaria OUAOUJA
Zakaria OUAOUJA le 9 Juin 2023
I've run two simulations (Base and Novel models), each one has 3 outputs, and I want to plot the results in two categories as shown below. I've done this manually.
Thank you.
  4 commentaires
Simon Chan
Simon Chan le 10 Juin 2023
Could you show us the code how you plot those lines and legend?
Rik
Rik le 10 Juin 2023
How exactly did you add it manually? Why can't you put the code you used in a script (or function)?

Connectez-vous pour commenter.

Réponse acceptée

Subhajyoti Halder
Subhajyoti Halder le 21 Juin 2023
Hello Zakaria,
It is my understanding that it is required to plot the output of two simulations which are having three outputs.
Please find the below example implementation:
t = linspace(200, 0, 100)
t = 1×100
200.0000 197.9798 195.9596 193.9394 191.9192 189.8990 187.8788 185.8586 183.8384 181.8182 179.7980 177.7778 175.7576 173.7374 171.7172 169.6970 167.6768 165.6566 163.6364 161.6162 159.5960 157.5758 155.5556 153.5354 151.5152 149.4949 147.4747 145.4545 143.4343 141.4141
% dummy output of base-model
base_model = log(sort(40*rand(100,3)))
base_model = 100×3
-2.0435 -1.9239 -1.2994 -0.5290 -1.2485 -0.5876 -0.4008 -0.5735 -0.5295 -0.2382 0.3371 -0.2568 -0.0746 0.5827 -0.0801 0.2774 0.7390 -0.0746 0.5607 0.7997 -0.0440 0.7839 0.8578 0.0603 0.8034 1.0024 0.7629 1.0938 1.0293 0.8550
% dummy output of novel-model
novel_model = log(sort(40*rand(100,3)))
novel_model = 100×3
-1.1251 -0.4961 -2.4649 0.3427 -0.1944 -1.0079 0.6465 0.1873 -0.9030 0.8075 0.3214 -0.3550 1.0611 0.5776 -0.1914 1.2434 0.8334 0.2168 1.2565 0.9245 0.3183 1.3019 1.3471 0.4129 1.3886 1.4617 1.1928 1.6147 1.5705 1.4676
yyaxis left
plot(t,base_model,Color='b')
ylabel('base model')
yyaxis right
plot(t,novel_model,Color='r')
ylabel('novel model')
title('Temperature at various depth (Base model vs co-sim Twalk-in = -20*C')
xlabel('time')
legend('Center','Top Surface','Bottom Surface')
In this example, it is plotting the values of both the models in the same plot, with their axes on either vertical side, while the common time-axis at the bottom.
For more details on the plot function, kindly go through the following documentation link -

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by