Can not run function, written wrong?
1 次查看(过去 30 天)
显示 更早的评论
I can nor run the function and do not understand where I have written it wrong.
0 个评论
采纳的回答
Star Strider
2019-10-11
The order is reversed. The ‘x’ variable needs to be assigned before calculating ‘y’, since ‘y’ depends on ‘x’.
2 个评论
Star Strider
2019-10-11
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 |')
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!