Matlab Solve a system of equations for a set of data
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Manuel Soler
am 3 Apr. 2020
Kommentiert: Manuel Soler
am 4 Apr. 2020
Hello,
So i want to solve this strain, stress problem by knowing 2 out of 6 unknowns and the 4 equations i need. I have a set of data for ex28 and ey28 of 9 values. I am noob to matlab and I started to write a code to solve it as follows:
E=73*10^9; v=0.33;
ey28=-1 *10^-6;
ex28=-3*10^-6;
syms sigmax28 sigmay28 ez28 sigmaz28;
eqn1=sigmax28==v*E*(ex28+ey28+ez28)/((1+v)*(1-2*v))+E/(1+v)*ex28;
eqn2=sigmay28==v*E*(ex28+ey28+ez28)/((1+v)*(1-2*v))+E/(1+v)*ey28;
eqn3=sigmaz28==v*E*(ex28+ey28+ez28)/((1+v)*(1-2*v))+E/(1+v)*ez28;
eqn4=ez28==sigmaz28/E-v/E*(sigmay28+sigmax28);
sol28=solve([eqn1, eqn2,eqn3,eqn4],[sigmax28,sigmay28,sigmaz28,ez28])
When solved, I get a 'struct' with very large numbers, so I have the feeling I am doing something wrong. I also could not figure out how to get the values from the struct without doubleclicking on it on the variable tree
I am also finding this process of going value by value very tedious, is there a way I could make the whole system of equations at once?
Thanks for throwing some light on it :)
0 Kommentare
Akzeptierte Antwort
John D'Errico
am 3 Apr. 2020
You get huge numbers, because you are trying to use symbolic tools here, but with double precision numbers. See what happens here:
x = (sqrt(5) + 1)/2
x =
1.61803398874989
>> sym(x)
ans =
910872158600853/562949953421312
At that point, x is just a number. You and I happen to know where it came from, but MATLAB does not. So in order to do exact arithmetic on it, the symbolic toolbox converts the floating point number to a ratio of integers. You can always convert a result to a floating point number using double, or to a floating point high precision number using vpa.
double(sym(x))
ans =
1.61803398874989
vpa(sym(x))
ans =
1.6180339887498949025257388711907
Don't trust those extra digits that vpa yields here, because there were only roughly 16 significant digits to start with.
double(sol28.sigmax28)
ans =
-190572.704674325
Weitere Antworten (1)
David Hill
am 3 Apr. 2020
You could just solve Ax=b (A\b):
E=73*10^9;
v=0.33;
ey28=-1*10^-6;
ex28=-3*10^-6;
b=[v*E*(ex28+ey28)/(1+v)/(1-2*v)+E*ex28/(1+v);v*E*(ex28+ey28)/(1+v)/(1-2*v)+E*ey28/(1+v);v*E*(ex28+ey28)/(1+v)/(1-2*v);0];
A=[1 0 0 -v*E/(1+v)/(1-2*v);0 1 0 -v*E/(1+v)/(1-2*v);0 0 1 -v*E/(1+v)/(1-2*v)-E/(1+v);v/E v/E -1/E 1];
x=A\b;
0 Kommentare
Siehe auch
Kategorien
Mehr zu Equation Solving finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!