# inverse matrix from result question

2 views (last 30 days)
pablolama on 4 Feb 2019
Edited: Omer Yasin Birey on 4 Feb 2019
I've a problem...
after this code, i obtain 14 2x2 matrix, how can i calculate the inverse of every matrix?
OA=1.42
AB=4.3
BO=3.33
OO=6
alfa=[19.7000, 10.2615, 0.8231, -8.6154, -18.0538, -27.4923, -36.9308, -46.3692, -55.8077, -65.2462, -74.6846, -84.1231, -93.5615, -103.0000];
beta= [37.3648, 40.5764, 43.6511, 46.4267, 48.7411, 50.4573, 51.4816, 51.7706, 51.3269, 50.1884, 48.4165, 46.0853, 43.2749, 40.0669];
gamma= [-68.0355, -66.333, -63.8261, -60.6513, -56.9882, -53.0279, -48.9467, -44.8871, -40.9515, -37.2048, -33.6824, -30.3996, -27.3598, -24.5623]
for i = 1:14
J = [AB*sind(beta(i)) BO*sind(gamma(i)); AB*cosd(beta(i)) BO*cosd(gamma(i))]
end
if i insert
for i = 1:14
Jinv= inv(J)
end
I have all equal invert matrix

Omer Yasin Birey on 4 Feb 2019
Edited: Omer Yasin Birey on 4 Feb 2019
Hi pablolama, you can use this for inverse of the each 2*2 matrix. In your code, you aren't storing the new J values. So, you would get 14 times of last J's inverse. You have to store them in a cell like below, in order to take inverse's of all of them.
OA=1.42
AB=4.3
BO=3.33
OO=6
J = cell(14,1);
alfa=[19.7000, 10.2615, 0.8231, -8.6154, -18.0538, -27.4923, -36.9308, -46.3692, -55.8077, -65.2462, -74.6846, -84.1231, -93.5615, -103.0000];
beta= [37.3648, 40.5764, 43.6511, 46.4267, 48.7411, 50.4573, 51.4816, 51.7706, 51.3269, 50.1884, 48.4165, 46.0853, 43.2749, 40.0669];
gamma= [-68.0355, -66.333, -63.8261, -60.6513, -56.9882, -53.0279, -48.9467, -44.8871, -40.9515, -37.2048, -33.6824, -30.3996, -27.3598, -24.5623]
for i = 1:14
J{i} = [AB*sind(beta(i)) BO*sind(gamma(i)); AB*cosd(beta(i)) BO*cosd(gamma(i))]
end
inverseJ = cellfun(@inv,J,'UniformOutput',false);