Matrix indexing collecting accurate results

1 回表示 (過去 30 日間)
Nikolaos Zafirakis
Nikolaos Zafirakis 2019 年 4 月 30 日
コメント済み: KSSV 2019 年 4 月 30 日
I have a for loop and some challenging mathematical equations my goal is to get a 3x3 matrix where A is preferable I would like to make A1 A2 cell matrices and collect the values leading to an easy final equation. Thanks in advance for anyone that helps me out!
for i = 1:100;
v2(1:3,i) = [cross(v1(1:3,i),(Sb(1:3,i)))/norm(cross(v1(1:3,i),(Sb(1:3,i))))]; % Works 3x1
w2(1:3,i) = [cross(w1(1:3,i),(Bb(1:3,i)))/norm(cross(w1(1:3,i),(Bb(1:3,i))))]; % Works 3x1
v3(1:3,i) = cross(v1(1:3,i),v2(1:3,i)); % Works 3x1
w3(1:3,i) = cross(w1(1:3,i),w2(1:3,i)); % Works 3x1
A1 = transpose([v1(1:3,i),v2(1:3,i),v3(1:3,i)]); % Works but donsn't store values 3x3
A2 = [w1(1:3,i),w2(1:3,i),w3(1:3,i)]; % Works but donsn't store values 3x3
A = mtimes(A1,A2); % Not working 3x3
end

採用された回答

KSSV
KSSV 2019 年 4 月 30 日
編集済み: KSSV 2019 年 4 月 30 日
A1 = zeros(3,3,100) ;
A2 = zeros(3,3,100) ;
A = zeros(3,3,100) ;
for i = 1:100;
v2(1:3,i) = [cross(v1(1:3,i),(Sb(1:3,i)))/norm(cross(v1(1:3,i),(Sb(1:3,i))))]; % Works 3x1
w2(1:3,i) = [cross(w1(1:3,i),(Bb(1:3,i)))/norm(cross(w1(1:3,i),(Bb(1:3,i))))]; % Works 3x1
v3(1:3,i) = cross(v1(1:3,i),v2(1:3,i)); % Works 3x1
w3(1:3,i) = cross(w1(1:3,i),w2(1:3,i)); % Works 3x1
A1(:,:,i) = transpose([v1(1:3,i),v2(1:3,i),v3(1:3,i)]); % Works but donsn't store values 3x3
A2(:,:,i) = [w1(1:3,i),w2(1:3,i),w3(1:3,i)]; % Works but donsn't store values 3x3
A(:,:,i) = mtimes(A1,A2); % Not working 3x3
end
  2 件のコメント
Nikolaos Zafirakis
Nikolaos Zafirakis 2019 年 4 月 30 日
Thank you for your response, A1 and A2 work perfectly on the other hand A is not working still would be helpful if you could provide some solution to this thanks in advance!
KSSV
KSSV 2019 年 4 月 30 日
Edited

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by