Error Dialogue box pops up too many times

2 次查看(过去 30 天)
I have a script with a simple check to see if there are too many consecutive Nan's. It uses a cubic spline interpolation to fix NaN's but I don't want it to interpolate if there more then 20 consecutive Nan's in the program. I have an error dialogue box that comes up in a loop, but if there is more than one spot with more than 20 consecutive NaN's the error box comes up multiple times. i only want the dialogue box to open once if there is 1 or more places with 20 consecutive NaN's. Here is what I did, is there a better solution to creating the error box?
if true
% code
check = flow;
check(~isnan(check))=0;
check(isnan(check))=1;
c=diff(check);
start=find(c==1)+1;
stop=find(c==-1)+1;
if length(stop)<length(start)
stop=[stop start(end)+1];
end
if length(start)<length(stop)
start=[start(1)-1 start];
end
out=stop-start;
for ii=1:length(out)
check(start(ii):(stop(ii)-1))=out(ii);
end
for ii=1:length(check)
if check(ii)>20
errordlg('too many consecutive missing points to interpolate check your data set', 'User Malfunction')
end
end

采纳的回答

Walter Roberson
Walter Roberson 2012-7-3
After the errordlg() call, still inside the "if", add the command
break;

更多回答(0 个)

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by