interp2 with loop

6 Ansichten (letzte 30 Tage)
Emilio  Alverio
Emilio Alverio am 8 Feb. 2018
Kommentiert: Emilio Alverio am 8 Feb. 2018
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 Kommentare
Stephen23
Stephen23 am 8 Feb. 2018
Bearbeitet: Stephen23 am 8 Feb. 2018
None of those square brackets are required, and only serve to make the code slower and more difficult to follow.
Emilio  Alverio
Emilio Alverio am 8 Feb. 2018
Thank you

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by