interp2 with loop

6 次查看(过去 30 天)
Emilio  Alverio
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by