Hello I am generating values of Itot from a while loop in which Itot is of different length in every iteration. MATLAB retains the order of the matrix Itot so every row contains zeros , except the largest. I am using this code to find the total number of elements in each row of Itot. cItot returns the value as a row vector.
for i=1:size(Itot,1) for c1=size(Itot,2):-1:1; if Itot(i,c1)~=0 cItot(i,1)=c1; break; end end end ---------- But this is highly inefficient, espicially when I have the order of Itot as 1000 by 24523210. Is there an efficient way to do this?