How can I get the X and Y coordinates from an fplot graph? or from a function by parts?
9 views (last 30 days)
Show older comments
Juan Soriano
on 24 Jun 2019
Commented: Juan Soriano
on 24 Jun 2019
Hi,
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:
[x1,y1]=fplot(...,...)
[x2,y2]=fplot(...,...)
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;
Mdestot=(mcar*acc+0.5.*Cd.*A.*ro.*(acc.*t_f).^2).*rr;
Mdescte=(0.5*Cd*A*ro*(acc*3.7)^2)*rr;
Mdessub=(mcar*g*sin(3)+0.5*Cd*A*ro*(acc*3.7)^2)*rr;
Mfinalrueda = piecewise(0<=t_f<=3.7, Mdestot,3.7<= t_f <=10, Mdescte, 10<=t_f<=15,Mdessub,15<=t_f<=20, 0);
Mfinalres=Mfinalrueda/3.45;
mfinalres=Mfinalres/Mb;
[x1,y1] =fplot(mfinalres,[0,20]);
I_des=Mfinalres/0.75;
[x2,y2]=fplot(I_des,[0,20]);
When I tried using XData and YData, I did something similar to:
h=fplot(mfinalres,[0,20]);
x1=get(h,'XData');
y1=get(h,'YData');
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
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!