Datatip not working. Changing location??
Afficher commentaires plus anciens
I cannot click on my graph for some wierd reason but whatever i just assumed i could use the datatip command to show the max of my graph.
When i wrote the code the location of DataTip changes for some wierd reason.
Any ideas?
I posted my code blow
heres the value of the variables
m0 = [ 41 91 331]
This is the frequency of the plot
f0 = [ 1 2 0.3]
This is the amplitude of the graph
This the command window it reads:
ans =
DataTip (X 0, Y 3.399e-16) with properties:
Why is it changing the location of the DataTip??
p= plot(f,P1);
m0=find(P1>0.1)
f0=P1(:,[m0])
datatip(p,f0,m0)
3 commentaires
Walter Roberson
le 16 Sep 2020
What is size(P1) ?
f0=P1(:,[m0])
implies it might have multiple rows. If P1 is not a row vector then find() is returning linear indexing not column indexing.
John Emberson
le 17 Sep 2020
John Emberson
le 17 Sep 2020
Réponses (1)
Walter Roberson
le 17 Sep 2020
0 votes
You are passing in vectors of x and y coordinates, but datatip is only defined for scalar x and y.
In terms of your plot, f is your independent variable and P1 is your dependent variable. You are extracting some of the P1 entries and passing them in as x coordinates to datatip, and you are passing in indices as your y coordinates to datatip.
When you pass in x and y coordinates, datatip is defined to place the datatip at the nearest point to what you pass in.
You should be passing in f(m0(1)) as your x and f0(1) as your y to datatip()
1 commentaire
John Emberson
le 17 Sep 2020
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!