How to plot different iterations into one figure at the same time in order to compare the difference in time
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have the following code:
clc;
close all;
clear all;
load CS1.mat
Days_SATP= CS1([1:21:189],[2]);
L_ATP= CS1([2:21],[1]);
for j=(1:9);
Sw= CS1([(2+(21*(j-1))):(21*j)],[2]);
mat(j,:)=Sw;
end
figure;
H = plot(L_ATP,mat(1, :));
title('Aqueous phase')
xlabel('Length (-)')
ylabel('Saturation')
axis([0 1 0 1])
for k = 2:9
pause(0.5);
set(H, 'YData', mat(k, :));
end
load CS2.mat
for j=(1:9);
Sw= CS2([(2+(21*(j-1))):(21*j)],[2]);
mat(j,:)=Sw;
end
figure;
H = plot(L_ATP,mat(1, :));
title('Aqueous phase')
xlabel('Length (-)')
ylabel('Saturation')
axis([0 1 0 1])
for k = 2:9
pause(0.5);
set(H, 'YData', mat(k, :));
end
which gives me two plots after each other for a different data set. How can I plot both the data of CS1 and CS2 simultaneously in one figure, so that I can see the difference between CS1 and CS2 in the figure more clearly?
I tried the following, with different tries for the set(...) part, but I can't figure it out:
clc;
close all;
clear all;
load CS1.mat
load CS2.mat
L_ATP= CS1([2:21],[1]);
for j=(1:9);
Sw= CS1([(2+(21*(j-1))):(21*j)],[2]);
mat(j,:)=Sw;
Sw2= CS2([(2+(21*(j-1))):(21*j)],[2]);
mat2(j,:)=Sw2;
end
figure;
H = plot(L_ATP,mat(1, :),L_ATP,mat2(1,:));
%title,lables,axis
for k = 2:9
pause(0.5);
set(H, 'YData', (mat(k, :),mat2(k,:)));
end
Regards,
Martin
0 Kommentare
Antworten (1)
Rutuja Shirali
am 7 Dez. 2015
Hi Martin,
To retain current plot while adding new plots, use the "hold" function. More information about this can be found here:
-Rutuja
0 Kommentare
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!