Dear scholars,
I have 1 question. 1 need to do 45 iteration. at iteration = 40, the value of RMSE suddenly overshoot. I want to end current loop (exploration stage) and go another loop (exploitation stage) doing another method until the iteration is finish. can someone help me to do this loop.

2 个评论

You need to use two loops, Something like
while i < 45
i = i + 1;
% code
if rapid_change
%restart exploration
end
end
for iter=1:50
do %optimization code using ANN
% got the optimal point
%computer RMSE
end
if (iter > 20)
increase= RMSE_all (iter)-RMSE_all(iter-1)
percentage_increase=(increase./RMSE_all(iter-1)).*100
Percent(iter,:)=percentage_increase;
if (percentage_increase> 50)%if the percentage more than 50%
%the previous row was larger than the current row, break the loop
break; %( if increase more than 50, doing exploitation only)
% if percentage increase more than 50 percent, the algorithm perform
% exploitation only
end
else
iter= iter + 1;
end
I already do as above code, the problem is, if the loop break, i dont know how to go another loop doing same another optimization method of algorithm then complete the iteration till 50 iteration.

请先登录,再进行评论。

 采纳的回答

Simple example
p = [0.0979 0.1915
0.2707 0.1944
0.4505 0.2968
0.5541 0.4605
0.5956 0.6184
0.6210 0.2617
0.7016 0.2851
0.7523 0.3436
0.7938 0.4488
0.8214 0.6038
0.8422 0.3553
0.8813 0.3670
0.9182 0.4225
0.9412 0.4985
0.9643 0.3699];
x = p(:,1);
y = p(:,2);
x1 = linspace(x(1),x(end));
y1 = interp1(x,y,x1);
a = atan2( diff(y1),diff(x1) ); % angle of each line
dt = abs(diff(a))*180/pi; % angle between neighbour lines in degrees
color = rand(1,3);
plot(x,y)
axis equal
for i = 2:length(x1)-1
if dt(i-1) > 40 % if angle between lines is large (rapid change)
color = rand(1,3);
end
line(x1(i),y1(i),'color',color,'marker','*')
pause(0.1)
end

更多回答(0 个)

类别

帮助中心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!

Translated by