How to plot two arrays which different time stamps and lengths in one plot?
조회 수: 7 (최근 30일)
이전 댓글 표시
Hello everyone,
I have Data extracted from a csv which looks like:
A=[0.1 0.2 0.35 0.42] which represents the time and with the corresponding B=[1 4 9 12 20] data
and I have another Data set with
C=[0.01 0.4 0.5 0.8 1 2 10] which also is the time and the corresponding data D=[5 7 10 11 12 3 1]
How can I plot both vectors B and D over one time line?
I tried to extend the vector A and fill it up with zeros for the missing time stamps, but in the plot the last point and the first one were connected by a line for data A .
Any ideas?
Thank you very much for your help
Helmut
댓글 수: 0
답변 (1개)
Fangjun Jiang
2021년 2월 18일
%%
A=[0.1 0.2 0.35 0.42];
B=[1 4 9 12];
C=[0.01 0.4 0.5 0.8 1 2 10];
D=[5 7 10 11 12 3 1];
[x,index]=sort([A,C]);
y=[B,D];
y=y(index);
plot(x,y)
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!