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

조회 수: 9 (최근 30일)
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

채택된 답변

madhan ravi
madhan ravi 2019년 6월 24일
h = fplot(mfinalres,[0,20]);
x1 = h.XData
y1 = y.YData

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by