Find index in each column of a matrix using for
1 visualizzazione (ultimi 30 giorni)
I am attempting to find the index of the last non-NaN for each column in a matrix. I can't really get it to work correctly; instead of giving me a column vector of indices, it sums the indices together in every cell. Here is my code:
xDate=zeros(1,size(forward,2)); % preallocate a vector
xDate=xDate'; % transpose to a column
for i = 1:size(forward,2)
xDate(i) = find(~isnan(forward),1,'last')
I'm sure it is an easy fix; but I've been racking my brain on it for hours now with no solution.
Thanks to all who are generous enough to help.