Function for Compliance Matrix
Afficher commentaires plus anciens
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;
Réponses (1)
KALYAN ACHARJYA
le 4 Sep 2019
Modifié(e) : KALYAN ACHARJYA
le 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 commentaires
Jide Williams
le 4 Sep 2019
Modifié(e) : Jide Williams
le 4 Sep 2019
Jide Williams
le 4 Sep 2019
KALYAN ACHARJYA
le 4 Sep 2019
Modifié(e) : KALYAN ACHARJYA
le 4 Sep 2019
Can you share following three things? Run the code and type the following one by one in command window as follows, and requested you to share the details
>>whos Tinv
>>whos Tinv
>>whos S
Jide Williams
le 4 Sep 2019
KALYAN ACHARJYA
le 4 Sep 2019
Because I considered the same sizes random data, its works in my case. I showed the example also
Jide Williams
le 4 Sep 2019
Jide Williams
le 4 Sep 2019
Modifié(e) : Jide Williams
le 4 Sep 2019
KALYAN ACHARJYA
le 4 Sep 2019
Modifié(e) : KALYAN ACHARJYA
le 4 Sep 2019
Have you mentioned this "I want it to return 3*3*19" in the original question?
I sepcifically asked for share the followings
>>whos Tinv
>>whos Tinv
>>whos S
Run the code and Type whos Tinv on commnad window, then enter, show the details here
.....do the same for others
KALYAN ACHARJYA
le 4 Sep 2019
In your case
Tinv is 3x3
T is 3x3
S is 3x3x2
Can you show, how you can get 3*3*19 after doing multiplication from those matrices?
I am asking basic Maths, not Matlab?
Jide Williams
le 4 Sep 2019
Jide Williams
le 4 Sep 2019
KALYAN ACHARJYA
le 4 Sep 2019
Happy to know that the problem has been resolved
Good Wishes!
Jide Williams
le 4 Sep 2019
Catégories
En savoir plus sur Numerical Integration and Differentiation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!