I have the following code:
A =[1 2 3;
1 0 1;
0 5 1;
1 0 2;
2 3 2];
[row,~] = find(A(1:4,[1,2]),1,'last');
What I was hoping to achieve through the above code is to find the last non-zero rows for individual columns. So my expected answer was
However, with the above code, the answer I am getting is
I have done it with a for loop, but with the size of data I have, it is computationally expensive to do loops. I was hoping to get it done without loops.
Thank you in advance for your kind contribution.