MATLAB Answers

Solving a system of 4 equations to find the cosine directions from stress matrix and principle stress

21 views (last 30 days)
Trevor Palmer
Trevor Palmer on 18 Sep 2021 at 20:36
Edited: David Goodmanson on 19 Sep 2021 at 9:55
I want to solve the 4 equation system to find my variables l,m,n. These represent the cosine directions for my specific princple stresses. Here is an example of what the equations look like:
I want to be able to make a quick calculator that I can feed in a stress matrix of 3x3 to fill all the sigmas with sub scripts and then input in my principle stresses one at a time to find l,m,n for each corrosponding prinicple stress, sigma.
Here is my current code, I have not written the section on how I store the three sets of l,m,n values after I use the linsolve function:
stress = [110 60 0; 60 -86 0; 0 0 55]
eigs = eig(stress);
lmn = zeros(3,3);
syms l m n
for i =1:length(eigs)
eq1 = l*(stress(1,1)-eigs(i))+m*stress(1,2)+n*stress(1,3)==0;
eq2 = l*stress(2,1)+m*(stress(2,2)-eigs(i))+n*stress(2,3)==0;
eq3 = l*stress(3,1)+m*stress(3,2)+n*(stress(3,3)-eigs(i))==0;
eq4 = (l^2)+(m^2)+(n^2)==1;
[A,B] = equationsToMatrix([eq1, eq2, eq3, eq4], [l, m, n]);
X = linsolve(A,B)
end
But i get the error:
Error using mupadengine/feval_internal
Unable to convert to matrix form because the system does not seem to be linear.
Error in sym/equationsToMatrix (line 61)
T = eng.feval_internal('symobj::equationsToMatrix',eqns,vars);
Error in Palmer_hw3 (line 18)
[A,B] = equationsToMatrix([eq1, eq2, eq3, eq4], [l, m, n]);
I suspect it doesnt like 4 equations with only three variables.
-Thanks!
  1 Comment
Kelly Smith
Kelly Smith on 19 Sep 2021 at 5:27
I think you have a problem setting up your system of equations. The first 3 rows are linear in l, m and n, while every term of the last row is non-linear. If you make the last row linear, l+m+n=1 the system will be inconsistant because your have the constraint that l, m or n must not be zero from the first 3 equations. If you make the last row linear and consistant i.e., l+m+n=0, then the only solution to the system will be trival, l=m=n=0.

Sign in to comment.

Accepted Answer

David Goodmanson
David Goodmanson on 19 Sep 2021 at 9:46
Edited: David Goodmanson on 19 Sep 2021 at 9:55
Hi Trevor,
After taking the terms involving sigma over to the right hand side, the equations are just the eigenvalue equation written out:
stress*eigvec = eigvec*eigval
with eigvec being the column vector [l;m;n] and eigval being a particular eigenvalue. The fourth equation is simply the statement that eigvec is normalized to 1. Looking at all three solutions, then
stress*lmn = lmn*eigvals
where lmn is the 3x3 matrix of eigenvectors as columns, and eigvals is the diagonal matrix of eigenvalues. So all the variables you are looking for are contained in lmn. This becomes
stress = [110 60 0; 60 -86 0; 0 0 55]
[lmn eigvals] = eig(stress)
% make sure that each eigenvector is normalized to 1 (not really necessary
% since eig produces normalized eigenvectors already)
for k = 1:3
lmn(:,k) = lmn(:,k)/norm(lmn(:,k));
end
% check, should be small (similarly for columns 2 and 3)
stress*lmn(:,1) - lmn(:,1)*eigvals(1,1)
It's best to stay away from 'eigs' as a variable name since eigs is already a Matlab function.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!