Interpolating between values of unknown function in MATLAB
Interpolating between values of unknown function in MATLAB
Author
Discussion

W00DY

Original Poster:

16,780 posts

257 months

Tuesday 13th April 2010
quotequote all
Probably not specific to MATLAB really. But i'm creating a program where i have a list of torqu values at specific RPMs and i want to linearly interpolate between them for a specific RPM. As it isn't a defined function i have no idea where to start and would appreciate any help.

Thanks
A mech Eng student who hates computing.

johnaachen

668 posts

248 months

Tuesday 13th April 2010
quotequote all
Tq=[100 150 200 300 450]; %your torque vector
NE=[1000 2000 3000 4000 5000]; %your engine speed vector

NE_New=1500;%The engine speed you want to know the torque at

Tq_New=interp1(NE,Tq,NE_New) % The torque at N_New engine speed

Hope that helpssmile

Or if you want linear interpolation by hand:-

idx=min(find(NE_New>NE));
prop=(NE_New-NE(idx))/(NE(idx+1)-NE(idx));
Tq_New=Tq(idx)+prop*(Tq(idx+1)-Tq(idx))

Edited by johnaachen on Tuesday 13th April 23:31

W00DY

Original Poster:

16,780 posts

257 months

Monday 19th April 2010
quotequote all
Thanks for that, really appreciated and worked well.