Doubt comparison of rows
조회 수: 1 (최근 30일)
이전 댓글 표시
I have the following array and I want to compare column 7 elements of this matrix. I want to compare
- (1,7) to (2,7) - (3.7) with (4.7)
and so on but considering that the initial matrix dimensions may change:
0 0 0 0 97790 0.0652150716905635
0 0 0 1 94450 0.0629876625541847
0 0 1 0 94954 0.0633237745915305
0 0 1 1 91739 0.0611797265755252
1 0 1 0 94135 0.0627775925308436
1 0 1 1 91051 0.0607209069689897
1 1 0 0 95302 0.0635558519506502
1 1 0 1 92901 0.0619546515505168
1 1 1 0 92341 0.0615811937312437
1 1 1 1 89610 0.0597599199733244
for this I tried to use the following code:
if true
% code
n)length(X);
for i=1:n;
if X(i,6) < X(i+1,6);
jj(i)=1;
else jj(i)=0;
end
end
end
But I do not operate correctly because I want to compare rows 1 to 2, the 3 and the 4, the 5 with the 6th .....
Many thanks
댓글 수: 0
채택된 답변
Andrei Bobrov
2013년 11월 6일
A = [0 0 0 0 97790 0.0652150716905635
0 0 0 1 94450 0.0629876625541847
0 0 1 0 94954 0.0633237745915305
0 0 1 1 91739 0.0611797265755252
1 0 1 0 94135 0.0627775925308436
1 0 1 1 91051 0.0607209069689897
1 1 0 0 95302 0.0635558519506502
1 1 0 1 92901 0.0619546515505168
1 1 1 0 92341 0.0615811937312437
1 1 1 1 89610 0.0597599199733244];
delta = A(1:2:end) - A(2:2:end,:)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!