MATLAB Answers

how to produce a logical matrix using index matrix

2 views (last 30 days)
Khairul Nur
Khairul Nur on 24 Oct 2019
Edited: 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.

Accepted Answer

per isakson
per isakson on 24 Oct 2019
Try
logical_matrix = false( 1, 4 );
logical_matrix( b ) = true;

  3 Comments

Khairul Nur
Khairul Nur on 24 Oct 2019
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!!

Sign in to comment.

More Answers (0)

Tags


Translated by