How to plot different iterations into one figure at the same time in order to compare the difference in time
조회 수: 5 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Rutuja Shirali
2015년 12월 7일
Hi Martin,
To retain current plot while adding new plots, use the "hold" function. More information about this can be found here:
-Rutuja
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!