MATLAB: Assign values to a matrix from a 2 dimensional array….

image analysisimage processingMATLABMATLAB and Simulink Student Suitematrixmatrix arraymatrix manipulation

Think I have a 2-dimensional array(Assume that x and y co-ordinations). And I want to assign '1' to all those co-ordinations given in the array(If the matrix values all are Zeros). How to do that Task ?

Best Answer

a(a==0)=1; % done!
Look up "matrix addressing" in documentation