Kraft=500:1000:1510;Geschwindigkeit=10:50:160;DrehzahlICE=1484DrehmomentICE=50DrehmomentAchsesoll= Kraft*0.324;DrehmomentAchseist=DrehmomentICE*1.54*2.64;Drehmomentbrauch=DrehmomentAchsesoll-DrehmomentAchseist;idx2 =Drehmomentbrauch<0;idx3 =Drehmomentbrauch>=0;Drehmomentbrauch1=Drehmomentbrauch.*idx2;Drehmomentbrauch2=Drehmomentbrauch.*idx3;while Drehmomentbrauch1< -1 | Drehmomentbrauch2 > 1if Drehmomentbrauch1 < -1 DrehmomentICE = DrehmomentICE -0.4; DrehmomentAchseist=DrehmomentICE*1.54*2.64; Drehmomentbrauch=DrehmomentAchsesoll-DrehmomentAchseist;elseif Drehmomentbrauch2 > 1 DrehmomentICE = DrehmomentICE + 0.4; DrehmomentAchseist=DrehmomentICE*1.54*2.64; Drehmomentbrauch=DrehmomentAchsesoll-DrehmomentAchseist; end
this code works perfectly for only negative or only positive values but if the vector contains both then it skips the loop
the problem can be seen in the current example
basically i want to calculate it to get a vector of DrehmomentICE at end
Best Answer