i need to jump to the begining of the page or to the first loop in the 'end'
4 views (last 30 days)
Show older comments
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 Comments
Image Analyst
on 17 Dec 2013
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???
Answers (1)
Walter Roberson
on 17 Dec 2013
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 Comments
Image Analyst
on 17 Dec 2013
This will execute 10 times:
for k = 1 : 10
k = 10;
end
This will execute once
k = 1;
while k <= 10
k = 10;
end
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!