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 个评论
Kobi
Kobi 2013-12-17
the problem is that this type of matlab calculation after the inner most loop (line 49) reach to the 'end' it begins to loop right back to the begining (line 47) so the resault is that the most inner loop repeats itself a lot of time, causing the script to take something like 5 minuts to run i need to change each variable at a time
Image Analyst
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
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.

类别

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