I can not plot values

5 views (last 30 days)
esat gulhan
esat gulhan on 7 Sep 2020
Commented: Stephan on 7 Sep 2020
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

Accepted Answer

Stephan
Stephan on 7 Sep 2020
Edited: Stephan on 7 Sep 2020
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 Comments
Steven Lord
Steven Lord on 7 Sep 2020
You can try to solve once then substitute values for alfa2 into the solution using subs.
Stephan
Stephan on 7 Sep 2020
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])

Sign in to comment.

More Answers (0)

Categories

Find more on Matrices and Arrays 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!