Solving a system of equations using Symbolic Matlab

4 Ansichten (letzte 30 Tage)
Man Rsgo
Man Rsgo am 18 Aug. 2023
Bearbeitet: John D'Errico am 18 Aug. 2023
Hi, I am working with symbolic variables for the first time and I am struggling when it comes to solving systems of equations. I have tried the typical methods I would use to solve it if it were not symbolic, but in this case, I can't seem to make it work.
The system of equations, expressed matrix-wise, that I am trying to solve is the following one:
in which the 6x6 matrix is known, the loads vector (left hand side) is symbolic and the strains vector (remaining one) is the unknown. I created F as
F = @(x) [Nx; Ny; Nxy; Mx; My; Mxy] - [Aij, Bij; Bij, Dij]*[x(1); x(2); x(3); x(4); x(5); x(6)];
where Aij, Bij and Dij are the 3x3 matrices shown in the previous image, therefore, what I want to do is that I want to find the strains as a function of the loads, but I do not get the desired result using fsolve, neither the typical x=A\b.
If it helps, at the beggining of the code I declared:
syms Nx Ny Nxy Mx My Mxy t
Aij = [99.18 19.3 0; 19.3 27.50 0; 0 0 22.02]*t;
Bij = [0 0 -2.24; 0 0 -2.24; -2.24 -2.24 0]*t^2;
Dij = [11.55 0.56 0; 0.56 1.10 0; 0 0 0.78]*t^3;
How would you solve the previous system of equations?
Thank you.
  1 Kommentar
Man Rsgo
Man Rsgo am 18 Aug. 2023
Bearbeitet: Man Rsgo am 18 Aug. 2023
I have also tried
syms Nx Ny Nxy Mx My Mxy epsx epsy gamxy kx ky kxy t
F = [Nx; Ny; Nxy; Mx; My; Mxy] - [Aij, Bij; Bij, Dij]*[epsx; epsy; gamxy; kx; ky; kxy];
x = solve(F)
but it solves for epsx, gamxy, kx, kxy, ky and t, in that order, and I want to find epsx, epsy, gamxy, kx, ky, kxy plus the result is a structure with 2x1 fields for each variable, and it should be 1x1

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

John D'Errico
John D'Errico am 18 Aug. 2023
Bearbeitet: John D'Errico am 18 Aug. 2023
You CANNOT use fsolve, though you said you tried it. This is not a numerical problem, but a symbolic one. t is an unknown there.
syms t
Aij = [99.18 19.3 0; 19.3 27.50 0; 0 0 22.02]*t;
Bij = [0 0 -2.24; 0 0 -2.24; -2.24 -2.24 0]*t^2;
Dij = [11.55 0.56 0; 0.56 1.10 0; 0 0 0.78]*t^3;
First, build the 6x6 matrix.
M = [Aij,Bij;Bij,Dij]
M = 
Next, what are the knowns? The unknowns?
syms Nx Ny Nxy Mx My Mxy % these will be the knowns, though for now, we don't know them.
LHS = [Nx; Ny; Nxy; Mx; My; Mxy];
syms epsx epsy gamxy kx ky kxy % these are the unknowns. also unknown. ;-)
X = [epsx; epsy; gamxy; kx; ky; kxy];
Now the solve is almost trivial. But you need to tell solve what to solve for! The second argument to solve does that. As you can see, I give it a list of the unknowns to solve for.
sol = solve(LHS == M*X,[epsx epsy gamxy kx ky kxy])
sol = struct with fields:
epsx: (25*(45920*Mxy + 41081*Nx*t - 25091*Ny*t))/(87182412*t^2) epsy: (25*(447328*Mxy - 25091*Nx*t + 180857*Ny*t))/(87182412*t^2) gamxy: (2*(864*Mx + 17584*My + 8851*Nxy*t))/(307151*t^2) kx: (4*(48011*Mx - 18284*My + 3024*Nxy*t))/(2150057*t^3) ky: (2*(178081*My - 5224*Mx + 17584*Nxy*t))/(307151*t^3) kxy: (50*(735925*Mxy + 5740*Nx*t + 55916*Ny*t))/(21795603*t^3)
Or, I could have used backslash at this point, just M\LHS, but solve does a nice job of returning the list of unknowns, and connecting them to their found values directly.

Weitere Antworten (0)

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by