Filter löschen
Filter löschen

I have a matrix equation system and I need help to solve it

3 Ansichten (letzte 30 Tage)
mahdi
mahdi am 24 Mai 2023
Bearbeitet: Torsten am 10 Jun. 2023
So I have these 3, 7*1 variable matrices in those system of equations and C{1,1} and C{1,2} are 7*7 matrices and they are constant, also S_1 to S_15 are 1*7 constant matrices. Problem is, it gives me U=0, W=0 and PHI=0 and it doesnt calculate the variables in those U, W and PHI matrices.
syms U [7 1]
U;
syms W [7 1]
W;
syms PHI [7 1]
PHI;
syms U W PHI
eq1 = (S_1*C{1,2}*U)+(S_2*C{1,1}*U)-(S_3*U)+(S_4*C{1,2}*W)+(S_5*C{1,1}*W) == 0;
eq2 = (S_6*C{1,2}*PHI)+(S_7*C{1,1}*PHI)+(S_8*PHI)-(S_9*C{1,1}*W) == 0;
eq3 = (S_10*C{1,2}*W)+(S_11*C{1,1}*W)+(S_12*C{1,1}*PHI)+(S_13*PHI)+(S_14*C{1,1}*U)...
-(S_15*U) == 0;
[U, W, PHI] = solve([eq1, eq2, eq3],[U, W, PHI])
  44 Kommentare
mahdi
mahdi am 10 Jun. 2023
Bearbeitet: mahdi am 10 Jun. 2023
Ok thanks, can you explain this line please:
eq1(7) = subs(eq1(7),lhs(eq1(7)),lhs(eq1(7))+sym('100'));
Is this like the line b(7) = -100; ?
Also I must write this whole process after the end of this right?
{}; % for example only
C{1,1} = rand(7);
C{1,2} = rand(7);
Nu = 0.285; A_11 = 64; A_55 = 37; D_11 = 2; w0c = 0.005; R = 0.5;
A11 = 6.4*10^4; A55 = 3.7*10^4; D11 = 2*10^3;
N = 7; a = 0; b = 0.5;
X1 = a+(b-a)*(1-cos(((1:N)-1)*pi/(N-1)))/2;
syms r
w0 = w0c*cos(pi*r/(2*R));
w0onX1 = double(subs(w0,r,X1));
A = C{1,1}*w0onX1.';
B = C{1,2}*w0onX1.';
B1 = C{1,2}*w0onX1.';
C_1 = cell2mat(C(1));
al = zeros(N);
al(2:N,1:N) = C_1(2:N,1:N);
bl = zeros(N);
bl(1:N-1,1:N) = C_1(1:N-1,1:N);
syms U [N,1]
syms W [N,1]
syms PHI [N,1]
z1 = X1;
z2 = B.';
z3 = A.';
z4 = B1.';
Ug1 = 0; Ug2 = 0; Ug3 = 0;
atm=((2*A11*z1.^2).*(C{1,2}))+(((2*A11*z1).*(C{1,1}))-(2*A11));
atm2=(((A11.*z2).*(z1.^2)).*(C{1,2}))+(((((A11-(Nu*A11)).*z3).*z1).*(al)));
atm3=((D11*z1.^2).*C{1,2})+((D11*z1).*C{1,1})-(D11+(A55*z1.^2));
atm4=((A55*z1.^2).*(al));
atm5=((((2*A55*z1)+((2*A11*Ug2).*z1)+((A11*z2.^2).*z1)+(2*Nu*A11*Ug3)).*C{1,2})+...
((2*A55)+(2*A11*Ug2)+((2*A11*Ug1).*z1)+(A11*z3.^2)+(((A11*z4).*z3).*z1).*(al)));
atm6=(((2*A55*z1).*C{1,1})+(2*A55));
atm7=((((2*Nu*A11)+((2*A11*z4).*z1)).*C{1,1})+(2*Nu*A11*z4));
eq1 = (atm*U)+(atm2*W) == 0;
eq2 = (atm3*PHI)-(atm4*W) == 0;
eq3 = (atm5*W)+(atm6*PHI)+(atm7*U) == 0;
vars = [U;W;PHI];
[Omega,b] = equationsToMatrix([eq1,eq2,eq3],vars);
b(7) = -100;
sol = Omega\b;
JabejayiU = double(sol(1:N));
KhizW = double(sol(1+N:N+N));
TaghirzaviyePHI = double(sol(1+(2*N):N+(2*N)));
Then again for example after I wrote all these and the nonlinear system, I must write the iteration procces? Or I can just combine the loop with the nonlinear system?
Torsten
Torsten am 10 Jun. 2023
Bearbeitet: Torsten am 10 Jun. 2023
Is this like the line b(7) = -100; ?
Yes.
And the code I gave you is complete - no modifications are necessary.
Of course I don't know whether "fsolve" returns a valid and reasonable solution. Nonlinear equations can have none or multiple solutions in contrast to linear systems.
Instead of
f = matlabFunction([lhs(eq1);lhs(eq2);lhs(eq3)],"Vars",{[U;W;PHI]})
[sol,fval] = fsolve(f,zeros(21,1))
you can also try
sol = vpasolve([eq1;eq2;eq3],[U;W;PHI])
to see if you get a different solution.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by