Can not run function, written wrong?

 Respuesta aceptada

Star Strider
Star Strider el 11 de Oct. de 2019

0 votos

The order is reversed. The ‘x’ variable needs to be assigned before calculating ‘y’, since ‘y’ depends on ‘x’.

2 comentarios

Hanna Sundling
Hanna Sundling el 11 de Oct. de 2019
yeah, I changed that so x is assigned before y but when I plot the graph does not look like it is supposed to. So I thought that i maybe have written the function wrong?
Note that ‘y’ will be complex, since you are taking the square root of a negative numbers in ‘x’ and in some parts of ‘sin(x)’.
Try this:
x = -1:0.5:1;
y = (x-sqrt(x))./sqrt(sin(x));
plot(x, real(y), x, imag(y), x,abs(y))
grid
legend('Re(y)', 'Im(y)', '| y |')

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graph and Network Algorithms en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 11 de Oct. de 2019

Comentada:

el 11 de Oct. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by