필터 지우기
필터 지우기

INTERPOLATED POINTS WHILE Plotting

조회 수: 15 (최근 30일)
heir ancestors
heir ancestors 2017년 4월 6일
댓글: heir ancestors 2017년 4월 6일
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