The interpolation interp1 command is taking wrong values.

1 Ansicht (letzte 30 Tage)
kajal shah
kajal shah am 3 Feb. 2017
Beantwortet: cr am 6 Feb. 2017
The command line is
Te_loop_max(i)=interp1(Ne,Temax,pbatt_const_Ne(i),'cubic')
inside a loop; The Temax,Pbatt are taking wrong values, . So the interpolation is coming 0 always. I am working on embedded function, simulink. Display and print command showing different values of Temax
disp(fprintf('Temax=%10.3f',Temax));
Te_loop_max(i)=interp1(Ne,Temax,pbatt_const_Ne(i),'cubic');
disp(fprintf('Ne=%10.1f, Temax=%10.3f, pbatt=%10.3f',Ne,Temax,pbatt_const_Ne(i)));
output: Temax= 12.515Temax= 12.628Temax= 13.337Temax= 13.449Temax= 13.188Temax= 13.188Temax= 12.814Temax= 12.142Temax= 10.759Temax= 9.564
Ne= 2000.0, Temax= 2500.000, pbatt= 3000.000Ne= 3250.0, Temax= 3500.000, pbatt= 4000.000Ne= 4500.0, Temax= 5000.000, pbatt= 5500.000Ne= 6000.0, Temax= 12.515, pbatt= 12.628Ne= 13.3, Temax= 13.449, pbatt= 13.188Ne= 13.2, Temax= 12.814, pbatt= 12.142Ne= 10.8, Temax= 9.564, pbatt= 2000.000 343
Please suggest

Antworten (1)

cr
cr am 6 Feb. 2017
Generally, Ne and Temax are expected to be vectors. It is not clear why the statement is inside a loop. If you want to find interpolated values at various values of pbatt_const_Ne make it a vector too.

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