interp2 with loop

6 visualizaciones (últimos 30 días)
Emilio  Alverio
Emilio Alverio el 8 de Feb. de 2018
Comentada: Emilio Alverio el 8 de Feb. de 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 comentarios
Stephen23
Stephen23 el 8 de Feb. de 2018
Editada: Stephen23 el 8 de Feb. de 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 el 8 de Feb. de 2018
Thank you

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by