Datatip not working. Changing location??
Ältere Kommentare anzeigen
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 Kommentare
Walter Roberson
am 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
am 17 Sep. 2020
John Emberson
am 17 Sep. 2020
Antworten (1)
Walter Roberson
am 17 Sep. 2020
0 Stimmen
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 Kommentar
John Emberson
am 17 Sep. 2020
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!