MATLAB Answers


How can I get the X and Y coordinates from an fplot graph? or from a function by parts?

Asked by Juan Soriano on 24 Jun 2019
Latest activity Commented on by Juan Soriano on 24 Jun 2019
I am relatively new to maltab. I am trying to get the X and Y coordinates of a function by parts I plotted with fplot. I tried doing the following:
However, I kept receiving a warning that said: 'Having two output arguments for fplot will be removed in a future release. Use the XData and
YData properties instead. ' Also, I think that x1 and y1 could have different lengths, and I needed them to have the same length.
I leave you here the following code I wrote:
syms t_f;
Mfinalrueda = piecewise(0<=t_f<=3.7, Mdestot,3.7<= t_f <=10, Mdescte, 10<=t_f<=15,Mdessub,15<=t_f<=20, 0);
[x1,y1] =fplot(mfinalres,[0,20]);
When I tried using XData and YData, I did something similar to:
but did not work, because apparently you can't name an fplot.
So yeah, basically I'm stuck trying to obtain the x and y coordinates from a function by parts (I want to make a two column matrix, with the same length later on, that's why I would like them to be the same length).
Hope I explained myself clearly. Please tell me if I did not.(English is not my first language)
Thank you very much in advance


Sign in to comment.

1 Answer

Answer by madhan ravi
on 24 Jun 2019
 Accepted Answer

h = fplot(mfinalres,[0,20]);
x1 = h.XData
y1 = y.YData

  1 Comment

haha I was going crazy, thank you very much!

Sign in to comment.