Error with interp1?

3 ビュー (過去 30 日間)
Shayma Al Ali
Shayma Al Ali 2021 年 8 月 24 日
コメント済み: David Goodmanson 2021 年 8 月 24 日
I have a variable, u10_B1B3, that is 851x1. I want it to be the same length as another variable, wc_B1B3, which is 7414x1, so I can plot the two against each other. I have tried interpolating the variable u10_B1B3 with the following line of code:
u10_B1B3=interp1(u10sdate,u10_B1B3,wcdate_B1B3,'nearest','extrap'); %interpolate u10_B1B3
where u10sdate is the dates corresponding to the u10_B1B3 data and wcdate_B1B3 are the dates corresponding to the wc_B1B3 data. However, I get the following error when I try to run it:
Error using interp1>reshapeAndSortXandV (line 445)
X and V must be of the same length.
Error in interp1 (line 128)
[X,V,orig_size_v] = reshapeAndSortXandV(X,V);
Error in datetime/interp1 (line 167)
vq = interp1(x,v,xq,method,extrapVal);
What can I do to fix the problem? Can I use another function instead of interp1?
  1 件のコメント
David Goodmanson
David Goodmanson 2021 年 8 月 24 日
Hi Shayma,
Interp1 is saying that the lengths of u10sdate and u10_B1B3 don't match. So, what are those two lengths?

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

回答 (1 件)

the cyclist
the cyclist 2021 年 8 月 24 日
You state "u10sdate is the dates corresponding to the u10_B1B3 data", but the error you are getting implies that u10sdate and u10_B1B3 are not the same length (so it is difficult for me to understand how they can correspond to each other).
Can you upload the data here, in a MAT file?

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by