[英]How to find the first zero column (or last non-zero column) in an array, greater than a certain column value
I have an array in which the first two columns are zero for all entries. 我有一个数组,其中所有条目的前两列均为零。 The array has non-zero values for some number of columns and then zeros in the rest.
该数组在某些列数上具有非零值,在其余列中具有零。 I wish to find the column that has the final non-zero (or first zero) entry that is not column 1 or 2, for plotting.
我希望找到具有最后非零(或第一个零)条目的列(不是列1或2)进行绘图。 I have tried
我努力了
find(b(i,:)==0,1)
找到(B(1,:)== 0,1)
which of course returns 1. 当然哪个返回1。
I have tried 我努力了
find(b(i,:)~=0,1)
找到(B(1,:)〜= 0,1)
which I thought would work, but bizarrely returns '2'. 我以为可以,但是奇怪地返回“ 2”。 I thought that find(b(i,:)~=0,1, 'last') might work instead, which I have seen being suggested as a MATLAB command on various Stack Overflow responses, however I still get '2'!
我认为find(b(i,:)〜= 0,1,'last')可能会代替,我已经看到它被建议作为各种堆栈溢出响应的MATLAB命令,但是我仍然得到'2'!
Any help would be much appreciated. 任何帮助将非常感激。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.