MATLAB Answers

0

how to produce a logical matrix using index matrix

Asked by Khairul Nur on 24 Oct 2019
Latest activity Edited by per isakson
on 24 Oct 2019
Hi, i need some help here, im also new in matlab. i have 'b' containing index matrix for example b=1; i want to create logical matrix and should be [1 0 0 0]
if i have b = 2, the matrix will be [0 1 0 0]. Hope i find some solutions. TQIA

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by per isakson
on 24 Oct 2019
 Accepted Answer

Try
logical_matrix = false( 1, 4 );
logical_matrix( b ) = true;

  3 Comments

actually i have 40 rows of data.. i try to fit in the code..
for n = i:40
Z=(D(i,:))
%function minmat return a= value min b=index min
[a,b] = minmat(Z)
DM(i,:) = false( 1, 4 );
DM(i,:)( b ) = true; %having some problem here!!
DM(i,b) = true;
great! its work..thank you very much :)

Sign in to comment.