how to use the result of current iteration as input for next iteration ?
4 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Walter Roberson
on 19 Nov 2022
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 Comments
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!