Plotting the graph of (4*x*sinx − 3)/(2 + x^2 )

9 views (last 30 days)
Tuna KISAAGA
Tuna KISAAGA on 3 Apr 2021
Answered: VBBV on 12 Apr 2023
f(x) = (4*x*sinx − 3)/(2 + x^2 ) for 0 ≤ x ≤ 4
How can I plot the graph of this function?
x=linspace(0,4,400);
y=((4.*x.*sin(x))-3)/(2+x.^2);
z=zeros(1,400);
figure
plot(x,y)
hold on
plot(x,z,'--')
title('Plot of (4*x*sin(x)-3)/(2+x^2)')
This code does not work.

Answers (1)

VBBV
VBBV on 12 Apr 2023
Use the element wise division for the equation
x=linspace(0,4,400);
y=((4.*x.*sin(x))-3)./(2+x.^2);
%^ use element wise division
z=zeros(1,400);
figure
plot(x,y)
hold on
plot(x,z,'--')
title('Plot of (4*x*sin(x)-3)/(2+x^2)');

Categories

Find more on Labels and Annotations 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!