i need to jump to the begining of the page or to the first loop in the 'end'
1 次查看(过去 30 天)
显示 更早的评论
hi,
i used the for loop as you can see in the attached image, i need to jump to the begining of the loop
i searched all over the internet but i couldn't find anything
i need index jumping
there is something like that in matlab
and if so, how can i use it?
i tryed using the break command every line before the 'end' it runs perfectly but it's ignoring the change of the index in the for index=1:....
or just to skip the line with the end?....
my cod:
for z_d=0:dz:z;
clc
disp('wait')
disp(length(z_d)-z_d)
for ind_r=1:length(x);
for ind_z=1:length(y);
for scan_recive
r_row=1:length(s);
for scan_reciver_col=1:length(s);
for scan_antena_row=1:length(s_0);
for scan_antena_col=1:length(s_0);
R=s_0(scan_antena_row,scan_antena_col)*(z-z_d)/(z-z_0)+s(scan_reciver_row,scan_reciver_col)*(z_d-z_0)/(z-z_0);
epsilon_new=epsilon_new+A*(exp(-((R-R_t)^2+(z_d-Z_t)^2)/2*a^2))*dz;
epsilon_print(ind_r,ind_z)=epsilon_new;
end
end
end
end
end
end
end
3 个评论
Image Analyst
2013-12-17
Well yeah. Because that's what you're telling it to do. If you don't want the inner loop to execute a bunch of times, why is it at the center of a bunch of other for loops???
回答(1 个)
Walter Roberson
2013-12-17
Each time you begin an iteration of a "for" loop, any change you made to the loop variable will be overridden.
If you need to be able to change values for a loop index, then use a "while" loop.
2 个评论
Image Analyst
2013-12-17
This will execute 10 times:
for k = 1 : 10
k = 10;
end
This will execute once
k = 1;
while k <= 10
k = 10;
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!