Doubt comparison of rows
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Andrei Bobrov
on 6 Nov 2013
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 Comments
More Answers (0)
See Also
Categories
Find more on Function Creation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!