How to plot this function with the interval of [-2,2]?

9 次查看(过去 30 天)

回答(2 个)

Clay Swackhamer
Clay Swackhamer 2022-5-9
% Define x
x = linspace(-2,2,1000);
% Define function
y = x + 1-2*sin(pi*x);
% Estimate roots as values less than a tolerance
tol = 0.01
ix = find(abs(y)<tol)
% Plot function
plot(x,y)
hold on
% Plot roots
plot(x(ix), y(ix), 'ro')
% Add legend
legend('F(x)', 'Roots')

Star Strider
Star Strider 2022-5-9
Use fimplicit
syms x
f(x) = x + 1 - 2*sin(pi*x)
f(x) = 
figure
fimplicit(f, [-2 2])
grid
xlabel('x')
.

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by