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

조회 수: 13 (최근 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 CenterFile Exchange에서 Vector Volume Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by