Plotting 3 lines with different x values in one single plot?
조회 수: 7 (최근 30일)
이전 댓글 표시
Hi, I have data of absorbtion spectra of three different materials and I need to plot all of them on the same plot. The problem is that the X for each one isn't the same. For all of them the X axis is the wavelength but in one material this value jumps in 2 and in other it jumps in 25. This means that the wavelength (x value) of each material has a different length and not precisly the same values. However, I need all of them in one plot as in the following image:

My idea is to create a loop that eliminates the wavelengths that not match between the three materials (three vectros) but I don't know how to do it.
Thank you :)
댓글 수: 0
답변 (1개)
Star Strider
2020년 4월 18일
Example —
x1 = sort(rand(1,10));
y1 = rand(size(x1));
x2 = sort(rand(1,27));
y2 = rand(size(x2));
figure
plot(x1, y1)
hold on
plot(x2, y2)
hold off
grid
.
댓글 수: 12
Star Strider
2020년 4월 21일
I still have no idea what you want to do.
Try this:
y3 = interp1(x1, y1, x2, 'linear','extrap');
figure
loglog(x1, y1)
hold on
plot(x2, y2)
plot(x2, y2+y3)
hold off
grid
legend('\epsilon', 'H_2O', 'y_2+y_3')
.
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


