INTERPOLATED POINTS WHILE Plotting
15 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
heir ancestors
il 6 Apr 2017
Commentato: heir ancestors
il 6 Apr 2017
Hello everybody ;
I want to know that if there is any possibility to know all the graphs points in a matlab Plot.
What I mean by this : If I will plot a graph for given values of xx' axis for example [1:1:6]
Is there a possibility to know all the coordinates of the the graph ( in the example fx and fy) ?
here for example a short code :
A=(1:1:6);
fx=2.*cosd(A);
fy=100*sind(A);
figure(3)
plot(A,fx,'r.-')
hold on
plot(A,fy,'g.-')
legend('sinfunction','cosfunction')
the figure is showed as joined to this post ;
How to know all the coordinates of fx how to know all the coordinates of fy how to know the intersection poitns between fx and fy
2 Commenti
Adam
il 6 Apr 2017
cosd and sind are how you know the intermediate points, but when you define a sample rate as you have done in A then this defines the accuracy with which you will see the results on the graph. You can increase the granularity of A to get more accuracy, but you will always have a discrete plot.
The intersection points can be estimated from the graph I suppose, but would seem to be more obviously calculated mathematically from the functions themselves.
Risposta accettata
John D'Errico
il 6 Apr 2017
Modificato: John D'Errico
il 6 Apr 2017
Suppose you plot a line, as just two points, between (0,1) and (2,4).
h = plot([0 2],[1 4],'o-')
h =
Line with properties:
Color: [0 0 1]
LineStyle: '-'
LineWidth: 0.5
Marker: 'o'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [0 2]
YData: [1 4]
ZData: [1×0 double]
You can now extract the points that you plotted.
h.XData
ans =
0 2
h.YData
ans =
1 4
But MATLAB does not allow you to extract all the points in between along that line segment. Of course, there are infinitely many of them. But even if your goal is to obtain the pixelated points along that line, you still cannot do so. Sorry.
Nothing stops you from using interpolation to obtain a set of interpolated points. interp1 will help you there. But that is all you can do.
Finally, it looks like you are looking to compute an intersection of two curves in a plot.
The simp[lest way to do this, if you have actual functions, is to use a tool like fzero. Subtract the functions, then solve for a zero point.
If you want to do this form data points, then use a tool like Doug Schwarz's intersections.m, available from the file exchange.
If you want to do it from a plot itself, then you need to extract the points from the plot, then use intersections on the extracted curves.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Line Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!