Azzera filtri
Azzera filtri

How can I plot the result of FZERO?

2 visualizzazioni (ultimi 30 giorni)
Nathanael
Nathanael il 13 Ott 2011
I have this problem using fzero: Find the x-axis crossing of the function y=20*x^3+25 in range of -20 to 20. Plot the curve with the answers on it.
Can anyone assist me plotting the answers? My answer look like: fzero('20*x^3+25',-30) ans = -1.0772
Thanks

Risposta accettata

Naz
Naz il 13 Ott 2011
If you plot the function in the range from -20:20, you can see, that it crosses the x-axis around -1.0772 (and probably nowhere else). If you need to plot the function, here's a possible way:
x=-20:0.1:20; % '0.1' is an arbitrary increment dx
y=20*x.^3+25;
plot(x,y);
In the current case the dx=0.1, and for plotting the -1.0772 you need to make this dx<0.0001, however, the full value the matlab gives is -1.077217345015942 (which is also rounded), thus theoretically, you would need to set your dx<10^-15. Plotting your answer does not make sense. You could put a text over the plot with your answer:
text(0,.5*10^5,'-1.0772')

Più risposte (0)

Categorie

Scopri di più su Optimization in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by