How to prepare a matrix with variables that contain a range of values?
4 views (last 30 days)
Show older comments
This is my first time writing matlab code and I am struggling. I am trying to write a transformation matrix for compliance and stiffness tensors matrices. The tranformation matrix is supposed to be Tsigma=[c^2 s^2 2cs; s^2 c^2 -2cs; -cs cs c*2-s^2] where c=cos(x) and s=sin(x) and x=-pi/2:pi/16:pi/2. This is what I had typed in which I know is completely wrong but I do not know where to begin. I keep getting a complicated matrix that says I cannot take the inverse of it, even though I need to. I need a series of 3x3 matrices with the different values of x put in but cannot seem to get it.
S is the compliance matrix and was defined as: S=[1/E1 -v12/E1 0; -v12/E1 1/E2 0; 0 0 1/G12] where E1=155; E2=12; v12=0.25; G12=5
The end goal is to determine Sbar=inv(Tsigma)*S*Tepsilon and Qbar=inv(Sbar). Tepsilon=[c^2 s^2 cs; s^2 c^2 -cs; -2sc 2sc c^2-s^2]. I had trouble getting this matrix to work out as well.
Any help or direction to get started would be very much appreciated!
0 Comments
Answers (1)
Stephan
on 23 Apr 2021
Edited: Stephan
on 23 Apr 2021
syms c s x
% Tsigma
Tsigma = [c^2 s^2 2*c*s; s^2 c^2 -2*c*s; -c*s c*s c*2-s^2];
Tsigma = subs(Tsigma,[s, c],[sin(x), cos(x)])
% Tepsilon
Tepsilon = [c^2 s^2 c*s; s^2 c^2 -c*s; -2*s*c 2*s*c c^2-s^2];
Tepsilon = subs(Tepsilon,[s, c],[sin(x), cos(x)])
% S
E1 = sym(155);
E2 = sym(12);
v12 = sym(0.25);
G12 = sym(5);
S = [1/E1 -v12/E1 0; -v12/E1 1/E2 0; 0 0 1/G12]
% Sbar symbolic function
Sbar(x) = inv(Tsigma)*S*Tepsilon
% Qbar symbolic function
Qbar(x) = inv(Sbar)
% Symbolic values of pi for the x values
pi_const = sym(pi);
xvals = -pi_const/2:pi_const/16:pi_const/2;
% preallocate
SbarVals = sym('sbar', [3,3,numel(xvals)]);
QbarVals = sym('qbar', [3,3,numel(xvals)]);
% calculate the resulting matrices
for k = 1:numel(xvals)
SbarVals(:,:,k) = Sbar(xvals(k));
QbarVals(:,:,k) = Qbar(xvals(k));
end
% Show values
SbarVals(:,:,1)
QbarVals(:,:,2)
0 Comments
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!