first time user, need help with matrix variables?
1 view (last 30 days)
Show older comments
Hello,
I am looking for help on writing code for this problem. I am not looking for the answer so much as I am looking for some direction. So far, what I have done is the following: E1=155; E2=12; v12=0.25; G12=5; S=[1/E1 -v12/E1 0; -v12/E1 1/E2 0; 0 0 1/G12] and C=inv(S). As can be seen on the attached formula sheet, in order to get Sbar, I need Tsigma matrix and Tepsilon matrix. I set x=linspace(-pi/2, pi/2); s=sin(x); c=cos(x) as per the instructions. But, I am having difficulties moving on from there. I do not know how to get the Tsigma matrix as shown on the formula sheet and also do not know how I would plot it properly. I need to plot the following six positions in the Sbar matrix from x=-pi/2 to pi/2: S(1,1), S(1,2), S(1,3), S(2,2), S(2,3), and S(3,3).
Any help would be greatly appreciate as I am very confused!
0 Comments
Answers (1)
Steven Lord
on 25 Apr 2021
If your x vector were:
x = linspace(-pi, pi, 9)
As written this would give you a 3-by-27 matrix.
c = cos(x);
s = sin(x);
T = [c.^2, s.^2, 2*c.*s;
s.^2, c.^2, -2*c.*s;
-c.*s, c.*s, c.^2-s.^2];
size(T)
If you wanted a series of T matrices, one for each element of x, you could create T as a 3-dimensional array and take each page of that array in turn:
x2 = reshape(x, 1, 1, []);
c2 = cos(x2);
s2 = sin(x2);
T2 = [ c2.^2, s2.^2, 2*c2.*s2;
s2.^2, c2.^2, -2*c2.*s2;
-c2.*s2, c2.*s2, c2.^2-s2.^2];
size(T2)
Let's look at one of the pages, the one for x(2) which is essentially -3*pi/4.
format longg
T2(:, :, 2)
Or if you don't want to create the whole 3-dimensional array at once, you could write a function:
Tfun = @(x) [cos(x).^2, sin(x).^2, 2*cos(x).*sin(x);
sin(x).^2, cos(x).^2, -2*cos(x).*sin(x);
-cos(x).*sin(x), cos(x).*sin(x), cos(x).^2-sin(x).^2];
Tfun(x(2))
0 Comments
See Also
Categories
Find more on Vector Fields 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!