Effacer les filtres
Effacer les filtres

why does it not work on my matlab this example from the book

1 vue (au cours des 30 derniers jours)
Tor Fredrik Hove
Tor Fredrik Hove le 15 Oct 2011
Here are an example with matlab elseif and my attempt to rewrite it without success:
This is my script:
y=calcy(x)
if x<-1
y=1;
elseif x<=2
y=x^2;
else
y=4;
end
end
And why do they need two end. What are the two things they are ending?

Réponse acceptée

David Young
David Young le 15 Oct 2011
The second end is the end of the function. If you run the code outside a function, you must omit it.

Plus de réponses (0)

Catégories

En savoir plus sur Data Types dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by