Filter löschen
Filter löschen

How do I find the instersection on my plot?

1 Ansicht (letzte 30 Tage)
HelpAStudent
HelpAStudent am 11 Okt. 2021
Bearbeitet: Matt J am 11 Okt. 2021
I have a plot with the errorbar. The data coming from a matrix 21x6 and the errorbar from another matrix. I need to find where (for a given y-axis value) the functions intersect the curves and at what coordinate. Since the values of the graph are given by a matrix, only the y axis correspond to the physical values, for the x axis I changed the values via
xticks([1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21])
xticklabels({'-20','-18','-16', '-14', '-12', '-10', '-8', '-6','-4','-2','0','2', '4', '6', '8', '10', '12', '14', '16', '18', '20'})
The graph is this one:

Akzeptierte Antwort

Matt J
Matt J am 11 Okt. 2021
Bearbeitet: Matt J am 11 Okt. 2021
You can use fzero, e.g.,
fun=@(x)x^2;
y=4;
x_intersect=fzero(@(x) fun(x)-y,[0,1e6])
x_intersect = 2.0000
  12 Kommentare
HelpAStudent
HelpAStudent am 11 Okt. 2021
The meanbasketT is 21x6 that's why I have 6 function and 21 dots for function
Matt J
Matt J am 11 Okt. 2021
Bearbeitet: Matt J am 11 Okt. 2021
The ydata is not a particular column. The column as I told you before are the different line
Yes, the ydata in my original example also represented one particular line, but as I told you you can loop over your matrix columns and apply my technique to each.
xdata=-20:2:20
for i=1:6
ydata=Matrix(:,i);
y=...
fun=griddedInterpolant(xdata,ydata,'linear'); %interpolator
x_intersect(i) = fzero(@(x) fun(x)-y,[0,1e6])
end

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by