How can I plot this sine and cosine polynomial function? the code is giving me error, and not properly plotting the function... I need the x values to be in a range of 0<=x<=20

1 view (last 30 days)
x = linspace(0,20);
y = (sin(x) + cos(x))/(sin(x.^2));
fplot (y);

Answers (2)

Image Analyst
Image Analyst on 23 Nov 2016
Try this:
x = linspace(0, 20, 3000);
y = (sin(x) + cos(x)) ./ (sin(x.^2));
plot(x, y, 'b*-', 'LineWidth', 2);
grid on;

Star Strider
Star Strider on 23 Nov 2016
Do element-wise division as well as exponentiation:
syms x
y(x) = (sin(x) + cos(x))./(sin(x^2));
figure(1)
fplot(y, [0 20])

Community Treasure Hunt

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

Start Hunting!