MATLAB Answers

How can I solve this system of equation

5 views (last 30 days)
VinceUgo
VinceUgo on 24 Mar 2020
Answered: Alex Sha on 20 Apr 2020
r=0.18;
lambda=0.9;
a0=0.4;
a1=0.15;
kc=1.37*10^3;
b=0.089;
kpsi=8.14*10^5;
s_LB=0.4;
beta_LB=5;
psi=37;
W=30;
c=0.8;
syms thetaF thetaR thetaM sigmaLB jx KXsym tx Fz h theta
eqn1= thetaF==double(acosd(1-h/r));
eqn2= thetaR==double(acosd(1-lambda*h/r));
eqn3= thetaM==double((a0+a1)*thetaF);
eqn4= sigmaLB==double(r*((kc/b)+kpsi)*(cosd(theta)-cosd(thetaF)));
eqn5= jx==double(r*(thetaF-theta-(1-s_LB)*(sind(thetaF)-sind(theta))));
eqn6= KXsym==double(0.043*beta_LB+0.036);
eqn7= tx==double((c+sigmaLB*tand(psi))*(1-exp(-jx/KXsym)));
eqn8= Fz==integral(@(theta)r*b*(tx*sind(theta)+sigmaLB*cosd(theta)),thetaR,thetaF);
eqn9= W==Fz;
[thetaSol,hSol]=vpasolve([eqn1 eqn2 eqn3 eqn4 eqn5 eqn6 eqn7 eqn8 eqn9],[theta,h]);
I hope you are all doing well despite the virus. My goal is to obtain the values of theta and h for Fz=W.
r, lambda, a0, a1, kc, b, kpsi, s_LB, beta_LB, psi, c and W are known constants. Because of MATLAB giving me the error "A and B must be floating-point scalars" in eqn8, I added the double(). Now I have the error Unable to convert "expression into double array". I made some research and I think it doesn't work because it is in a loop but I didn't clearly understand. That's why I am now asking for your help.
First I would like to know if MATLAB can resolve this system numerically? If yes, I would like to know where I made my error(s) to correct it (them). I'll add that I am using 2019b.
Thank you in advance for your help.
  3 Comments
Walter Roberson
Walter Roberson on 24 Mar 2020
You cannot use a symbolic variable in integrate()

Sign in to comment.

Answers (2)

Andreas Bernatzky
Andreas Bernatzky on 24 Mar 2020
Hey Vince Ugo,
you can not convert a variable into a symbolic expression (subsituting) and convert them into double() values and than expect a numerical solver to work with it. The double value first exists after you have run the numerical solver. But I see your struggle with the integrate function, because matlab expects double() Values here. you have to find another way to express the integral symbolic.
btw in this line you are using the variable "c". c is no where defined
eqn7= tx==double((c+sigmaLB*tand(psi))*(1-exp(-jx/KXsym)));
Have a look at this example of mine for a numerical solving of a overdetermined system:
clear all;
close all,
syms x y z
eqn1 = x + -0.25*y + (1/16) * z == 0;
eqn2 = x + 0.5*y + 0.25 * z == 1;
eqn3 = x + 2*y + 4*z == 0;
eqn4 = x + 2.5*y + (25/4)*z == 1;
% [Alin,B] = equationsToMatrix([eqn1, eqn2, eqn3], [x, y, z]);
[Alsq,B] = equationsToMatrix([eqn1, eqn2, eqn3, eqn4], [x, y, z]);%overdetermined system
% X = linsolve(Alsq,B);
Xlsqr = lsqlin(double(Alsq),double(B))
  3 Comments
VinceUgo
VinceUgo on 24 Mar 2020
Hi John D'Errico,
Thank you for your reply. However it seems that you have misunderstood something. Here sigmaLB depends of theta which is the variable used in the integral. tx depends also of exp(jx) which also depends of theta. That means, one needs to integrate tx and sigmaLB too. I don't think finding the solution with a pencil is easy looking on the equations of tx and jx.
I will try to rewrite my code with the advice you all gave me and see if I manage to make it work.

Sign in to comment.


Alex Sha
Alex Sha on 20 Apr 2020
Hi, VinceUgo, the eqn8 and eqn9 can be combined into one equation, so your problem become a system equation solving with eight equations but nine parameters, theoretically, there are mulit-solutions:
equations:
thetaF==(acosd(1-h/r));
thetaR==(acosd(1-lambda*h/r));
thetaM==((a0+a1)*thetaF);
sigmaLB==(r*((kc/b)+kpsi)*(cosd(theta)-cosd(thetaF)));
jx==(r*(thetaF-theta-(1-s_LB)*(sind(thetaF)-sind(theta))));
KXsym==(0.043*beta_LB+0.036);
tx==((c+sigmaLB*tand(psi))*(1-exp(-jx/KXsym)));
W==int(r*b*(tx*sind(theta)+sigmaLB*cosd(theta)),theta=thetaR,thetaF);
Solution 1:
thetaf: 17.2295894348337
thetar: 16.3392152094374
thetam: 9.47627418915823
sigmalb: 1789.79757276499
jx: 5.69410133255209
kxsym: 0.251000000000401
tx: 1349.50920963158
h: 0.00807740616102504
theta: -14.7346332116642
Solution 2:
thetaf: 11.2586858813269
thetar: 10.6792029310532
thetam: 6.19227723472841
sigmalb: 2872.23031726436
jx: 2.03819622278534
kxsym: 0.251000000000036
tx: 2164.53678066268
h: 0.00346397508336035
theta: -0.183693500487713
Solution 3:
thetaf: 11.257835094598
thetar: 10.6783961956676
thetam: 6.19180930202924
sigmalb: 2872.48939847845
jx: 1.99507014564293
kxsym: 0.251000000000372
tx: 2164.61121735673
h: 0.00346345326306647
theta: 0.0575803789775348

Community Treasure Hunt

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

Start Hunting!

Translated by