Is there a simpler way to find the index of the first non NaN value in a vector?

105 次查看(过去 30 天)
temp = X;
temp(~isnan(temp)) = 1;
temp(isnan(temp)) = 0;
temp = find(temp);
first_non_NaN_index_of_X = temp(1);

采纳的回答

OCDER
OCDER 2018-7-3
编辑:OCDER 2018-7-3
X= [NaN NaN 1 2 3 4 5];
first_non_NaN_index_of_X = find(~isnan(X), 1);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 NaNs 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by