finding the number of consecutive data
3 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a vector of 5000 obeservations containing nan values and prices. How can I tell if this vector contains 60 consecutive prices without any nan interruption?
0 个评论
采纳的回答
Thorsten
2013-2-1
This should do the job:
obs1 = observations(1);
Ncons = 1;
for i = 2:numel(observations)
if observations(i) == obs1
Ncons = Ncons + 1;
if Ncons == 60, break; end
else
obs1 = observations(i);
Ncons = 1;
end
end
if Ncons == 60
disp('60 consecutive prices found.')
end
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Financial Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!