Function for Compliance Matrix

조회 수: 5 (최근 30일)
Jide Williams
Jide Williams 2019년 9월 4일
댓글: Jide Williams 2019년 9월 4일
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;

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 9월 4일
편집: KALYAN ACHARJYA 2019년 9월 4일
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
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 9월 4일
Happy to know that the problem has been resolved
Good Wishes!
Jide Williams
Jide Williams 2019년 9월 4일
Thanks alot I appreciate your guidiance sir!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by