how can I display text of zero amplitude with text message

2 vues (au cours des 30 derniers jours)
Muhammad Ali Raza
Muhammad Ali Raza le 25 Mar 2023
Commenté : Walter Roberson le 26 Mar 2023
I have code below
t = -4:0.1:4;
y = t.^3-10*t;
plot(t,y)
when I run it the waveform displayed like below. how can I display the zero amplitude by using text command ?
  1 commentaire
Walter Roberson
Walter Roberson le 25 Mar 2023

Do you have code to find the location of the zeros?

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 26 Mar 2023
After having found the places that are zeros and storing the x coordinates in List_of_XCoordinates_Of_Zeros then
for xcoord = reshape(List_of_XCoordinates_Of_Zeros,1,[])
text(xcoord, 0, "X = " + round(xcoord,2));
end
  1 commentaire
Walter Roberson
Walter Roberson le 26 Mar 2023
syms t
eqn = 3*t.^5-10*t^3+5;
List_of_XCoordinates_Of_Zeros = double(vpasolve(eqn));
List_of_XCoordinates_Of_Zeros(imag(List_of_XCoordinates_Of_Zeros) ~= 0) = [];
fplot(eqn, [-2 2])
for xcoord = reshape(List_of_XCoordinates_Of_Zeros,1,[])
text(xcoord, 0, "X = " + round(xcoord,2));
end

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by