MATLAB: Find first non-zero column of a matrix MATLABmatrixnon-zero column How do I, given a matriz A, tell MATLAB to find the index of the leftmost non-zero column of said matrix? Best Answer >> A=[zeros(5) randn(5)]; A=A(:,randperm(10)); % sample datasetA = -0.7440 1.0223 0 -0.7062 0 0.1257 0 1.2390 0 0 -0.3744 -1.4192 0 -1.0207 0 0.6963 0 0.8987 0 0 0.4241 2.5467 0 1.1340 0 1.7395 0 -1.1501 0 0 0.1141 -0.3580 0 0.0385 0 0.6654 0 -0.2642 0 0 -0.5111 0.4013 0 0.2309 0 0.6875 0 -1.6252 0 0>> find(any(A),1) % first column nonzeroans = 1>>That one seems too easy; let's try again...>> A=A(:,randperm(10)); A = 0 -0.7440 0 0 1.0223 1.2390 0 0 0.1257 -0.7062 0 -0.3744 0 0 -1.4192 0.8987 0 0 0.6963 -1.0207 0 0.4241 0 0 2.5467 -1.1501 0 0 1.7395 1.1340 0 0.1141 0 0 -0.3580 -0.2642 0 0 0.6654 0.0385 0 -0.5111 0 0 0.4013 -1.6252 0 0 0.6875 0.2309>> find(any(A),1)ans = 2>>OK, that's more difficult and illustrates it does work as expected... Related SolutionsMATLAB: Which architecture and settings are the bets to predict the next value of a time series by time delay neural network If you only have 1 series, use NARNET help NARNET doc NARNETSearch BOTH the NEWSGROUP and ANSWERS using greg NARNETHope this helps.Thank you for formally accepting my answerGreg MATLAB: The project is about optimal pmu location considering zero injection bus & observability of pmu increament with pmu outages.nw i hv 2 getting into new thing.in this with matlab coding shown below.pls anyone suggest me the coding part of matrix….. See https://www.mathworks.com/help/optim/ug/intlinprog.html#btxncn9-6 on how to rewrite the calls to bintprog to more modern functions. Related QuestionA weird display of the outputChange binary string to decimalHow to perform fftCannot get the same result in GA as I get in linprogHow to place a cell array in another cell array using ‘find’Remove empty rows from matrix
Best Answer