Borrar filtros
Borrar filtros

INTERPOLATED POINTS WHILE Plotting

15 visualizaciones (últimos 30 días)
heir ancestors
heir ancestors el 6 de Abr. de 2017
Comentada: heir ancestors el 6 de Abr. de 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 comentarios
Adam
Adam el 6 de Abr. de 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.
heir ancestors
heir ancestors el 6 de Abr. de 2017
Thank you very much adam for your comment , this clarifies things for me. thanks again.

Iniciar sesión para comentar.

Respuesta aceptada

John D'Errico
John D'Errico el 6 de Abr. de 2017
Editada: John D'Errico el 6 de Abr. de 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.
  1 comentario
heir ancestors
heir ancestors el 6 de Abr. de 2017
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 : )

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by