Error in function at if-elseif
Mostrar comentarios más antiguos
I've got the error Output argument "val" (and maybe others) not assigned during call to "yt". yt(x) funtion:
function [val] = yt(x)
if ((-9<=x) & (x<-3)) | ((3<=x) & (x<=9))
val = sin(5*x);
elseif (-3<=x) & (x<3)
val = cos(x) - cos(3) - sin(15);
end
and i call the function using the following
x = -9:9;
val = yt(x)
I've got no output from this.
1 comentario
per isakson
el 10 de Mzo. de 2018
Editada: per isakson
el 10 de Mzo. de 2018
- Read the documentation on if-else-end
- See Debug a MATLAB Program
- It's good practice to have an else-clause
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!