How to add markers to a plot after using fzero
Show older comments
I am working on making a plot of y vs y'. I have constructed the plot and used the fzero function initialized at -4, -2, 0, 2, 4 to find all zeros of y'. I am trying to add these zeros to the plot already made as markers. Thanks for your help!
x=-2*pi : 2*pi;
y=3*x.*sin(x)-2*x;
y1=3*sin(x)+3*x.*cos(x)-2;
plot(x,y,'-',x,y1, '--')
xlabel('\bf\itx-axis\rm')
ylabel('\bf\ity-axis\rm')
legend('y=3xsin(x)-2x','y1=3sin(x)+3xcos(x)-2', 'Location', 'S')
x0 =-4; x1=-2; x2=0; x3=2; x4=4;
z0 = fzero('3*sin(x)+3*x.*cos(x)-2', x0)
z1 = fzero('3*sin(x)+3*x.*cos(x)-2', x1)
z2 = fzero('3*sin(x)+3*x.*cos(x)-2', x2)
z3 = fzero('3*sin(x)+3*x.*cos(x)-2', x3)
z4 = fzero('3*sin(x)+3*x.*cos(x)-2', x4)
Accepted Answer
More Answers (0)
Categories
Find more on Line Plots 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!