how to use the result of current iteration as input for next iteration ?
조회 수: 1 (최근 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!