how to use the result of current iteration as input for next iteration ?
4 次查看(过去 30 天)
显示 更早的评论
hello everyone!
this is my code in matlab, i want to put the result of x_new for the first iteration after doing optimization as input for the next iteration,
for example i have 10 iterations , at first i assign x_new at 0, and after each iteration it will be updated by the new value.
Do you have a suggestion?
x_new=0, %initialize x_new
for l=1: 10 %number of iteration
for i=1:m
for j=1:n
R_lb(i,j)=BP(i,j)*(log2(1+(Puissance(i,j)*(g0/n0(i,j)))/(sqrt(x_new(j)-Pos_c(i,j))^2+H^2))-(Puissance(i,j)*log2(e)*((sqrt(x(j)-Pos_c(i,j))^2)-(sqrt(x_new(j)-Pos_c(i,j))^2))*(g0/n0(i,j)))/((sqrt(x_new(j)-Pos_c(i,j))^2+H^2)*((sqrt(x_new(j)-Pos_c(i,j))^2+H^2)+(Puissance(i,j)*(g0/n0(i,j))))));
end
end
end
0 个评论
回答(1 个)
Walter Roberson
2022-11-19
for l=1: 10 %number of iteration
for i=1:m
xnew = zeros(1,n+1);
for j=1:n
R_lb(i,j)=BP(i,j)*(log2(1+(Puissance(i,j)*(g0/n0(i,j)))/(sqrt(x_new(j)-Pos_c(i,j))^2+H^2))-(Puissance(i,j)*log2(e)*((sqrt(x(j)-Pos_c(i,j))^2)-(sqrt(x_new(j)-Pos_c(i,j))^2))*(g0/n0(i,j)))/((sqrt(x_new(j)-Pos_c(i,j))^2+H^2)*((sqrt(x_new(j)-Pos_c(i,j))^2+H^2)+(Puissance(i,j)*(g0/n0(i,j))))));
xnew(j+1) = SomethingAppropriate
end
end
end
6 个评论
另请参阅
类别
在 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!