Clear Filters
Clear Filters

How to use interp1 in for loop?

4 views (last 30 days)
Akshay Apte
Akshay Apte on 24 Mar 2016
Edited: Walter Roberson on 24 Mar 2016
I have a curve representing engine power. I have to find a particular value on this curve where my engine power curve intersects. This I have to find at each step ranging from 1 to 1875 values. I used interp1 function but it gives error that it requires atlas 2 values to compute. My x-axis is Engine Power (Torque multiplied speed) and y-axis has either speed/torque. When I enter this graph with my engine power i need the point where I can find exact value on curve so that I would know the torque and speed for the power. Hoping for a positive reply
  2 Comments
Muhammad Usman Saleem
Muhammad Usman Saleem on 24 Mar 2016
Edited: Muhammad Usman Saleem on 24 Mar 2016
read documentations about interpolate1 it is interpolating data in one dimension. Please share data use and code you are trying
Akshay Apte
Akshay Apte on 24 Mar 2016
Edited: Walter Roberson on 24 Mar 2016
for it=1:numel(t)
%Battery power
if Pel(it)>0
%control strategy
socmin=0.3;
socmax=0.7;
if (soc(it-1)<socmin)||((soc(it-1)<socmax)&&(Switch==1))
r(it)=min(1,(soc(it-1)-socmin)/(socmax-socmin));
Peng1(it)=(1-r(it)).*((Pel(it)/EffPE)+Auxpower);
Eng_rpm_act(it)=interp1(Pool_engine(it),ool_speed_int(it),Peng1(it),'linear');
Eng_tq_act(it)=interp1(Pool_engine(it),ool_tq_int(it),Peng1(it),'linear');
Peng(it)=Eng_rpm_act(it).*Eng_tq_act(it)*pi/30;
end
This is just a part of the program. I need Eng_rpm_act and Eng_tq_act at each step. If there is another method please share. Pool_engine is the curve consisting of-ool_speed_int and oil_tq_int multiplied. Thanks

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!