## how to formulate logical matrix in a loop?

### Shubham Mohan Tatpalliwar (view profile)

on 24 Oct 2018
Latest activity Commented on by Andrei Bobrov

on 25 Oct 2018

### Andrei Bobrov (view profile)

i am having a matrix and want to separate them in the depending on its value
A=[1,2,3,4,5,6,7,8,9,10]
expected result are
idx1=[1,0,0,0,0,0,0,0,0,0] % for 1
...
idx10=[0,0,0,0,0,0,0,0,0,1] % for 10

### Andrei Bobrov (view profile)

on 25 Oct 2018

A = 1:10;
idx = A(:) == A(:)'

Shubham Mohan Tatpalliwar

### Shubham Mohan Tatpalliwar (view profile)

on 25 Oct 2018
what should i change to have a 5 rows with a step of 2
Andrei Bobrov

### Andrei Bobrov (view profile)

on 25 Oct 2018
what should i change to have a 5 rows with a step of 2
?
A = 1:2:10;
idx = A(:) == A(:)';

on 24 Oct 2018

on 24 Oct 2018

A=[1,2,3,4,5,6,7,8,9,10]
RESULT = zeros(1,numel(A));
RESULT1= RESULT;
for i = 1:numel(A)
idx(i)=A(i)==1;
idx1(i)=A(i)==10;
end
RESULT(idx) = A(idx)
RESULT1(idx1) = A(idx1)

on 25 Oct 2018
A=[1,2,3,4,5,6,7,8,9,10]
idy=zeros(1,length(A));
for i=1:1:10
idx22=find(A >=(i) & A<(i+1));
idy(i,idx22)=1;
end