Problem Using Interp1 Within For Loop

2 ビュー (過去 30 日間)
Jonathan Pinko
Jonathan Pinko 2020 年 4 月 30 日
コメント済み: Ameer Hamza 2020 年 5 月 1 日
I have the following code:
xq = dataset(1:116,1);
Fevq = zeros(length(xq),length(Fes));
for l=1:numel(Fes);
Fevq(l)=interp1(Fo(:,l),DeltaFe56(:,l),xq);
end
Fes is a 2x1 matrix, and both Fo and DeltaFe56 are both 126x2 matrices. I would like to interpolate the values of xq onto the (Fo,DeltaFe56) curves both when l=1, and when l=2. When I try to do this, however, I get the error message, "Unable to perform assignment because the left and right sides have a different number of elements".
I would like both sides to have the size of 116x2, and I am not sure why this isn't the case. Can anybody explain why this isn't working?
Thanks,
Jonathan

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 1 日
Try this
xq = dataset(1:116,1);
Fevq = zeros(length(xq),length(Fes));
for l=1:numel(Fes);
Fevq(:,l)=interp1(Fo(:,l),DeltaFe56(:,l),xq); % use Fevq(:,l) to indicate that you want to assign value to a column
end
  2 件のコメント
Jonathan Pinko
Jonathan Pinko 2020 年 5 月 1 日
This works perfectly, what a silly mistake on my part!
Thanks,
Jonathan
Ameer Hamza
Ameer Hamza 2020 年 5 月 1 日
I am glad to be of help.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by