Every 2 rows (2x2 matrix) to perform determinant calculation

8 ビュー (過去 30 日間)
cool dave
cool dave 2013 年 11 月 24 日
コメント済み: cool dave 2013 年 11 月 25 日
Hi all, can i know how to extract every two rows of my data to perform determinant calculation?
For example i have data:
1 2
3 4
5 6
7 8
9 10
11 12
so i want to select every two rows in order to perform determinant calculation, how can i do that? my final results should be:
-2
-2
-2
Regards,

採用された回答

Matt J
Matt J 2013 年 11 月 24 日
m=size(data,1);
i=1:2:m;
j=2:2:m;
determinants = data(i,1).*data(j,2)-data(j,1).*data(i,2),
  3 件のコメント
Matt J
Matt J 2013 年 11 月 25 日
編集済み: Matt J 2013 年 11 月 25 日
results = bsxfun(@times,r,n);
or
results = kron(r,[1;1]).*data
cool dave
cool dave 2013 年 11 月 25 日
it works perfectly. thank you so much mate :]

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

その他の回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 11 月 24 日
A=[1 2 ;3 4 ;5 6 ;7 8 ;9 10 ;11 12 ]
B=reshape(A',2,2,[])
out=arrayfun(@(x) det(B(:,:,x)),1:size(B,3))

cool dave
cool dave 2013 年 11 月 25 日
thank you so much of both of your responses, appreciate :)

カテゴリ

Help Center および File ExchangeVector Volume Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by