MATLAB: Location of non zeros locationnonzeros Hi there if I have a 100×1 matrix which has some zeros in it, how can i find the corresponding matrix of "locations" for all the cells which are non-zero. Eg, 1, 3, 2, 0 , 2, 4, 1, 0 , 0 Output: 1, 2, 3, 5, 6, 7, …… Best Answer >> A=[ 1, 3, 2, 0 , 2, 4, 1, 0 , 0]; >> locations = find(A) locations = 1 2 3 5 6 7 Related SolutionsMATLAB: Separating Matrix by Column By Pattern Sounds very easy:starttime = datetime(2018, 9, 10); %whatever your start issampletime = starttime + hours(0:size(sample, 2)-1);issampleweekend = isweekend(sampletime);sampleweekday = sample(:, ~issampleweekend);sampleweekend = sample(:, issampleweekend);A loop is certainly not needed. MATLAB: Remove array values with multiple occurances from “parent” array a = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4];b = [1, 1, 2, 4, 4, 4];c = a;for i=b c(find(c==i,1))=[];end Related QuestionNumber of non-zero elementI have two matrices that are related and I need to sort one matrix while sorting the corresponding matrix the same way.How to reshape a 3D array to 2D array along the diagonalsConstruct a lower triangular matrix with smaller matricesArea from XY coordniatesMatrix reduction to see how many various elements the matrix has
Best Answer