Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
If y(j) is less than some number (say 3) then I want to use higher value of k (say 4) but in the range of 5th iteration before and after y becomes 3. For example in 40th iteration y becomes 3. I want to use k=7 from 35th to 45th iteration. Pls help.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
N=100;
dt=0.05;
k=2;
t=zeros(N,1);
y=zeros(N,1);
y(1)=2;t(1)=0;
for j=1:N-1
t(j+1)=t(j)+dt;
y(j+1)=y(j)+dt*(2+k);
end
plot(t,y)
2 Kommentare
John D'Errico
am 26 Mär. 2018
Bearbeitet: John D'Errico
am 26 Mär. 2018
Your question is quite confusing, because the criteria seems to be depend on several things that are not really clear.
Regardless, what stops you from using an if statement to choose k, based on the value of y(j), or iteration, etc?
Antworten (0)
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!