INTERPOLATED POINTS WHILE Plotting

15 次查看(过去 30 天)
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 个评论
Adam
Adam 2017-4-6
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.
heir ancestors
heir ancestors 2017-4-6
Thank you very much adam for your comment , this clarifies things for me. thanks again.

请先登录,再进行评论。

采纳的回答

John D'Errico
John D'Errico 2017-4-6
编辑:John D'Errico 2017-4-6
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.
  1 个评论
heir ancestors
heir ancestors 2017-4-6
Thank you for resuming the situation and for this short course for the resolution of the problem. yes I was looking for the intersections of more complicated functions, so now I know that fzero function is the best way to do it . thank you again : )

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by