use goto, jump or some easier way for my loop in matlab?

2 次查看(过去 30 天)
I have this code
values_nodelay=no_of_values(2:2:end)
no_of_values_x1=(find(u~=[u(2:end), u(end)+1]));
no_of_values_x1=no_of_values_x1(2:2:end)
l=1;
delay=2;
values_delay=[];
while l<=length(values_nodelay)
values_delay_temp=values_nodelay(l)-delay;
if delay>values_delay_temp
end
values_delay=[values_delay, values_delay_temp];
l=l+1;
end
values_delay
i need a goto or jump function to the beginning of while, or if anyone know easier way maybe easier way, that if my delay>values_delay_temp i do not want to put in my final vector values_delay i wan to jump it and continue again with while loop. thanks guys

回答(1 个)

Sara
Sara 2014-6-9
You can change the condition in your if and put the value in values_delay only when delay<=values_delay_temp
while l<=length(values_nodelay)
values_delay_temp=values_nodelay(l)-delay;
if delay<=values_delay_temp
values_delay=[values_delay, values_delay_temp];
end
l=l+1;
end

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by