Y = X . COS(X) . SIN(X)
4 views (last 30 days)
Show older comments
Albert Barajas
on 21 Oct 2018
Commented: Image Analyst
on 4 Jan 2023
How would I go about plotting the following equation?
Y = X .* cos(X) .* sin(X);
5 Comments
Image Analyst
on 4 Jan 2023
@Shahid , I think you meant to post a new question rather than a comment here. I don't see how this would in any way be a comment or question for Albert. Please start your own question after you read this link.
Accepted Answer
Image Analyst
on 22 Oct 2018
You didn't say over what range to plot x, so I'm going to assume it's from -20 to 20. Adapt as needed:
% Choose a range for x and use 500 points.
X = linspace(-20, 20, 500);
% Create Y
Y = X .* cos(X) .* sin(X);
% Plot the function.
plot(X, Y, 'b-', 'LineWidth', 2);
grid on;
xlabel('X', 'FontSize', 15);
ylabel('Y', 'FontSize', 15);
title('Y = X .* cos(X) .* sin(X)', 'FontSize', 15);
axis equal;
% Make a black line at the x and y axes
line(xlim, [0, 0], 'Color', 'k', 'LineWidth', 2);
line([0, 0], ylim, 'Color', 'k', 'LineWidth', 2);

0 Comments
More Answers (2)
madhan ravi
on 21 Oct 2018
Edited: madhan ravi
on 22 Oct 2018
syms x %SYMBOLIC TOOLBOX
Y = x .* cos(x) .* sin(x)
fplot(Y)
or
x= linspace(-100,100,1000)
y=x .* cos(x) .* sin(x)
plot(x,y)
7 Comments
noor
on 9 Nov 2022
g(x)=cosx-sinx-0.5+x
1 Comment
Voss
on 9 Nov 2022
% Choose a range for x and use 500 points.
X = linspace(-20, 20, 500);
% Create Y
Y = cos(X) - sin(X) - 0.5 + X;
% Plot the function.
plot(X, Y, 'b-', 'LineWidth', 2);
grid on;
xlabel('X', 'FontSize', 15);
ylabel('Y', 'FontSize', 15);
title('cos(X) - sin(X) - 0.5 + X', 'FontSize', 15);
axis equal;
% Make a black line at the x and y axes
line(xlim, [0, 0], 'Color', 'k', 'LineWidth', 2);
line([0, 0], ylim, 'Color', 'k', 'LineWidth', 2);
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!