Function for Compliance Matrix
14 views (last 30 days)
Show older comments
I want to know what I am doing wrong with these codes
function y = Sbar(S,theta)
%Sbar This function returns the transformed reduced
% compliance matrix "Sbar" given the reduced
% compliance matrix S and the orientation
% angle "theta".
% There are two arguments representing S and "theta"
% The size of the matrix is 3 x 3.
% The angle "theta" must be given in degrees.
m = cosd(theta);
n = sind(theta);
T = [m*m, n*n, 2*m*n; n*n, m*m, -2*m*n; -m*n, m*n, m*m-n*n];
Tinv = [m*m, n*n, -2*m*n; n*n, m*m, 2*m*n; m*n, -m*n, m*m-n*n];
y = Tinv*S*T;
S = ReducedCompliance(155, 12.10, 0.248, 4.40)
theta = -90:10:90
for i = 1:length(theta)
S(:,:,i) = Sbar(S, theta(i))
end
%The output is
S =
0.0826 -0.0016 0
-0.0016 0.0065 0
0 0 0.2273
S(:,:,1) =
0.0826 -0.0016 0
-0.0016 0.0065 0
0 0 0.2273
S(:,:,2) =
0.0193 -0.0122 -0.0712
-0.0122 0.0909 0.0452
-0.0356 0.0226 0.2061
Error using *
Inputs must be 2-D, or at least one input must be scalar.
To compute elementwise TIMES, use TIMES (.*) instead.
Error in Sbar (line 13)
y = Tinv*S*T;
0 Comments
Answers (1)
KALYAN ACHARJYA
on 4 Sep 2019
Edited: KALYAN ACHARJYA
on 4 Sep 2019
May be, one way?
y=Tinv*T.*S;
Example:
>> Tinv
Tinv =
0.1361 0.5499 0.6221
0.8693 0.1450 0.3510
0.5797 0.8530 0.5132
>> T
T =
0.2417 0.1320 0.5752
0.4039 0.9421 0.0598
0.0965 0.9561 0.2348
>> whos S
Name Size Bytes Class Attributes
S 3x3x2 144 double
>> S(:,:,1)
ans =
0.4018 0.1233 0.4173
0.0760 0.1839 0.0497
0.2399 0.2400 0.9027
>> S(:,:,2)
ans =
0.9448 0.3377 0.1112
0.4909 0.9001 0.7803
0.4893 0.3692 0.3897
>> y
y(:,:,1) =
0.1266 0.1394 0.1073
0.0230 0.1079 0.0294
0.1282 0.3289 0.4558
y(:,:,2) =
0.2976 0.3819 0.0286
0.1485 0.5282 0.4612
0.2613 0.5062 0.1968
>>
13 Comments
See Also
Categories
Find more on Spectral Estimation 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!