Read vector until last value, or NANs start
5 次查看(过去 30 天)
显示 更早的评论
I have a vector array with an unknown number of entries. Either it will end nicely with the last entry being a number, or nans will start populating. I just need the index of the last actual number, not knowing if there's a next entry, or if the next is a nan.
Can you help?
Thanks!
0 个评论
采纳的回答
Walter Roberson
2018-7-8
lastidx = find(isnan(YourVector),1) - 1;
if isempty(lastidx); lastidx = length(YourVector); end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!