Interpolate y-values of two data sets on the same axes

10 ビュー (過去 30 日間)
Olivia Booth-Howe
Olivia Booth-Howe 2019 年 6 月 12 日
コメント済み: Matt J 2019 年 6 月 12 日
Hello,
I am writing a script in which I plot two sets of data on the same axes.
The first set contains data taken with one instrument, and the second contains data from another instrument. The y-axis is "height" and the x-axis is "temperature."
I am plotting the data from 0 to 4000 meters, but since the samples were taken from different instruments, data points do not occur at the exact same heights. Therefore, I am attempting to interpolate the y-variables of each of the two data sets onto the same grid. I do not want to interpolate the x-variables.
I cannot figure out how to properly use the interp function in order to achieve this.
Can anyone help? Please let me know if attaching my code will assist in understanding my question.
Thank you very much!

採用された回答

Matt J
Matt J 2019 年 6 月 12 日
編集済み: Matt J 2019 年 6 月 12 日
ht1=sortrows([height1(:),temperature1(:)]); %pre-sort
ht2=sortrows([height2(:),temperature2(:)]);
Height=ht1(:,1);
Temperature1=ht1(:,2);
Temperature2=interp1(ht2(:,1),ht2(:,2),Height);
plot(Temperature1,Height,'o',Temperature2,Height,'x')
  2 件のコメント
Olivia Booth-Howe
Olivia Booth-Howe 2019 年 6 月 12 日
Got it to work, thanks so much!
Matt J
Matt J 2019 年 6 月 12 日
You're welcome. Please Accept-click the answer, if it resolved your problem.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by