error using vpasolve involving 6 variables

1 view (last 30 days)
function rocker_bogie
H=input('height from ground');
p=input('density of material');
W=input('span of rover');
g=input('gravity');
d=input('diameter of wheel');
syms l4 a4 a3 l3 l2 a2 l1 a1 l5 l6 l7 l8 l9 xcom ycom m4 m5 m6 m7 m8 m9 d b y
l9=d/2+l1*sin(a1);
l6=l3*sin(a3);
l7=l2*cos(a3);
l5=l3*cos(a3);
l8=l1*cos(a1);
m4=p*l4;
m5=p*l5;
m6=p*l6;
m7=p*l7;
m8=p*l8;
m9=p*l9;
xcom=((m4*(-l4*cos(a4)/2))+(m5*l5/2+m6*l5+m9*l5-m9*l7+m5*(l5-l7/2)+m8*(l5+l8/2)+m9*(l5+l8)))/(m4+m5+m6+m7+m8+2*m9);
ycom=(m4*(H-(l4*sin(a4)/2))+m5*H+m6*(H-l6/2)+m9*(d/2+l9)+(m7+m8)*(l9+d/2))/(m4+m5+m6+m7+m8+2*m9);
b=asin(d/(sqrt((l1*cos(pi-a1-a2)-l2)^2+(l1*sin(pi-a1-a2))^2)))-atan((l1*cos(pi-a1-a2)-l2)/(l1*sin(pi-a1-a2)));
y=asin((l1*cos(pi/2-a1)+d/2)/(sqrt((l4-l3*cos(pi-a3-a4))^2+(l3*sin(pi-a3-a4))^2+(l3*sin(pi-a3-a4))^2)));
l1=l2;
a1=a2;
eqn1=l4*sin(a4)+d/2==H;
eqn2=l3*sin(a3)+l1*sin(a1)+d/2==H;
%eqn3=l3*sin(a3)+l2*sin(a2)+d/2==H;
eqn4=l4*cos(a4)+l3*cos(a3)+l1*cos(a1)+d/2==W;
eqn5=(l4*cos(a4)+xcom)/(ycom)==sqrt(3);
% eqn6=l1*cos(pi-a1-a2-b)-l2*cos(b)==d;
eqn7=l1*sin(pi-a1-a2-b)+l2*sin(b)==0.34;
% eqn8=l1*cos(pi/2-a1)+l3*sin(pi-(pi-a3-a4)-y)-l4*sin(y)==d/2;
eqn9=l1*sin(pi/2-a1)+l3*cos(pi-(pi-a3-a4)-y)+l4*cos(y)==W;
sol = vpasolve([eqn1, eqn2,eqn4,eqn5,eqn7,eqn9], [l1,l3,l4,a1,a3,a4]);
l1_sol=sol.l1;
l2_sol=sol.l2;
l3_sol=sol.l3;
l4_sol=sol.l4;
a1_sol=sol.a1;
a4_sol=sol.a4;
disp(l1_sol);
disp(l2_sol);
disp(l3_sol);
disp(l4_sol);
disp(a1_sol);
disp(a4_sol);
  2 Comments
Steven Lord
Steven Lord on 17 Jul 2019
What is the full and exact text (everything displayed in red) of the error message you receive?
What exact values did you specify for the five inputs that this code prompts you to enter?
Personally, I would split this into a computational function that accepts those parameters as input arguments and an interface function that includes the input statements and calls the computational function, passing the values the user entered at the input prompts as the input arguments. That way when you want to use the computational function in an automated fashion, you won't have to keep entering the parameters every time the function is called. Just use the computational function directly instead of calling the interface function first.
Jayesh Kumar
Jayesh Kumar on 18 Jul 2019
height was 0.36
density 2700
g=9.8
span=1.2
diameter =0.24
every thing is in SI units.
it would be helpful if u can provide code solution along with your intuitions .
thanks.

Sign in to comment.

Answers (1)

Mahesh Taparia
Mahesh Taparia on 6 Aug 2019
Hi,
Suggest you to check symbolic expression xcom, ycom, b and y as it has sin inverse operation which lies between –1 and 1. Removing these symbols from equation is giving the solution. Check whether they are correctly written or not.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!