Y = X . COS(X) . SIN(X)

4 views (last 30 days)
Albert Barajas
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
Shahid
Shahid on 4 Jan 2023
sinx(1+cosx) is maximum when x=pi
Image Analyst
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.

Sign in to comment.

Accepted Answer

Image Analyst
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);

More Answers (2)

madhan ravi
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
sharmeen shahid
sharmeen shahid on 21 Oct 2018
why don't you use the sin(x) part?
madhan ravi
madhan ravi on 22 Oct 2018
Missed it by mistake , check the edited answer now

Sign in to comment.


noor
noor on 9 Nov 2022
g(x)=cos⁡x-sin⁡x-0.5+x
  1 Comment
Voss
Voss on 9 Nov 2022
If you want to plot the function g(x), you can adapt @Image Analyst's answer:
% 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);

Sign in to comment.

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!