I'm trying to obtain a value between two points of vectors plotted against each other using the interp1 method, but the vale keeps coming up with NaN? Any suggestions>

1 次查看(过去 30 天)
Basically says it all in the question, but the line of code is as follows:
cet_3=interp1(Engine_Speed,Engine_Torque,ces_3);
both the Engine_Speed and Engine_Torque vectors are 1x15 vectors, and the ces_3 already has a single vale of around 55, however the value of cet_3 keeps coming out as NaN.

回答(1 个)

Walter Roberson
Walter Roberson 2015-12-7
cet_3 = interp1(Engine_Speed, Engine_Torque, ces_3, 'linear', 'extrap');
interp1() by default will only interpolate between min(Engine_Speed) and max(Engine_Speed) and will return NaN for other values. You need to tell it that it is okay to extrapolate for ces_3 values outside that range.

类别

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

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by