How to change a function within a loop at certain point in MATLAB
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have this piece of code:
x=0:20000;
h0=10;
alfa0=-0.1*pi/180;
h=h0+tan(alfa0).*x+10^(-6)*-0.4.*x.^2/(2*(cos(alfa0)^2));
Now, when executed it gives me this graph which shows that h is decreasing as x is increasing. ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/275358/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/275358/image.jpeg)
I would like Matlab to stop when h gets to 0, and then use a different function for h. Let's say
h=2.*x
so we have an actual example.
I tried some stuff with while loops and if statements, but I am getting nowhere. Thanks for the help.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!