interp2 with loop

6 ビュー (過去 30 日間)
Emilio  Alverio
Emilio Alverio 2018 年 2 月 8 日
コメント済み: Emilio Alverio 2018 年 2 月 8 日
Hello,
I am attempting to use the interp2 function with a for loop. The following code is what I have:
%% For loop for bsfc interpolation
for i = 1:1486
XqWG =[EngineRpm(1:41)];
YqWG(i,:) = [BrakeTorqueT(i)];
VqWG = interp2(X,Y,V,XqWG,YqWG);
end
where EngineRpm is a 1X41 and BrakeTorqueT is 1486X41. Here I need to hold each value of EngineRpm(XqWG) constant so that, that single value is used to interpolate against all BrakeTorqueT values (YgWG).
The problem right now is the interpolation uses only the first column value from EngineRpm for every subsequent column in BrakeTorqueT (IE EngineRpm never moves from (1,1) to (1,2) when proceeding through the loop).I need each of the 41 columns to be interpolated with the 41 columns of BrakeTorqueT. In other words, what I need is for the EngineRpm (1,1) to be a constant XqWG value for all YqWG (1:1486,1) in the first column of Vq, then EngineRpm (1,2) is constant (XqWG) for all YqWG (1:1486,2) etc. as the loop proceeds to interpolate all the data. I hope my question has been clear, I apologize in advanced for any confusion my wording causes. Thank you.
  2 件のコメント
Stephen23
Stephen23 2018 年 2 月 8 日
編集済み: Stephen23 2018 年 2 月 8 日
None of those square brackets are required, and only serve to make the code slower and more difficult to follow.
Emilio  Alverio
Emilio Alverio 2018 年 2 月 8 日
Thank you

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

回答 (0 件)

カテゴリ

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