I can not plot values

조회 수: 1 (최근 30일)
esat gulhan
esat gulhan 2020년 9월 7일
댓글: Stephan 2020년 9월 7일
When i try to plot results, plot is blank. I want to plot this a line.
syms Frx B m V1 V2 P1g P2g Frz alfa1 alfa2 A1 V M Degree Fr W Weight
m1=18;B1=1;P1g=0;V1=250;A1=1;alfa1=0;
m2=m1;B2=B1;P2g=0;V2=250;A2=1;Weight=0;
alfa2=0;
eq1=-Frx+P1g*A1==B2*m2*V2*cosd(alfa2) -B1*m1*V1*cosd(alfa1);
Frx=vpa(solve(eq1,Frx),10)
for alfa2=linspace(0,180,100)
plot(alfa2,Frx)
end

채택된 답변

Stephan
Stephan 2020년 9월 7일
편집: Stephan 2020년 9월 7일
syms Frx B m V1 V2 P1g P2g Frz alfa1 A1 V M Degree Fr W Weight
m1=18;B1=1;P1g=0;V1=250;A1=1;alfa1=0;
m2=m1;B2=B1;P2g=0;V2=250;A2=1;Weight=0;
alfa2=linspace(0,180,100);
eq1=-Frx+P1g*A1==B2*m2*V2*cosd(alfa2) -B1*m1*V1*cosd(alfa1);
% preallocate
Frx_num = zeros(1,numel(alfa2));
% solve in a loop --> VPA does not make sense, because for plot
% you have to convert to double
for k = 1:numel(alfa2)
Frx_num(k)=(solve(eq1(k),Frx));
end
% convert to double
Frx_num = double(Frx_num);
% plot
plot(alfa2,Frx_num)
  댓글 수: 3
Steven Lord
Steven Lord 2020년 9월 7일
You can try to solve once then substitute values for alfa2 into the solution using subs.
Stephan
Stephan 2020년 9월 7일
syms Frx B m V1 V2 P1g P2g Frz alfa1 alfa2 A1 V M Degree Fr W Weight
m1=18;B1=1;P1g=0;V1=250;A1=1;alfa1=0;
m2=m1;B2=B1;P2g=0;V2=250;A2=1;Weight=0;
eq1=-Frx+P1g*A1==B2*m2*V2*cosd(alfa2) -B1*m1*V1*cosd(alfa1);
% You want it faster
eq1_num = matlabFunction(rhs(isolate(eq1,Frx)),'Vars',{'alfa2'});
fplot(eq1_num,[0,180])

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by