필터 지우기
필터 지우기

How to update new value in next iteration?

조회 수: 3 (최근 30일)
Light
Light 2013년 5월 26일
How can i update that (ending value) U1t or U2t in next iteration.
U1t and U2t will be changed U1 and U2
(1st iteration ending value -> 2nd iteration starting value).
S12t=6+2*1i;
S01t=10+5*1i;
U1=110;
U2=110;
R12 = 16.2+24*1i;
U0i=115;
R01= 15.75+31.2*1i;
dx01=106.125;
dx12=81;
U20=10;
zoruu=0.01;
iteration_number = 0;
while true
iteration_number = iteration_number + 1;
fprintf('Starting iteration #%d\n', iteration_number);
dQ12=dx12*U2.^2*10.^-6;
S12i=S12t-complex(0,dQ12);
DS12 =((real(S12i).^2+imag(S12i).^2)/U2.^2)*R12;
S12ii=DS12+S12i;
S12e=S12ii-complex(0,dQ12);
S01i=S12e+S01t;
dQ01=dx01*U1.^2*10.^-6;
S01ii=S01i-complex(0,dQ01);
DS01=((real(S01ii).^2+imag(S01ii).^2)/U1.^2)*R01;
dQ01i=dx01*U0i.^2*10.^-6;
S01ii2=S01ii+DS01;
S01iii=S01ii2-complex(0,dQ01i);
dU01i=(real(S01ii2)*real(R01)+imag(S01ii2)*imag(R01))./U0i;
dU01ii=(real(S01ii2)*imag(R01)-imag(S01ii2)*real(R01))./U0i;
U1t=sqrt((U0i-dU01i).^2+dU01ii.^2);
dU12i=(real(S12ii)*real(R12)+imag(S12ii)*imag(R12))./U1t;
dU12ii=(real(S12ii)*imag(R12)-imag(S12ii)*real(R12))./U1t;
U2t=sqrt((U1t-dU12i).^2+dU12ii.^2);
Y=U1t-U1;
H=U2t-U2;
if max(Y,H)<zoruu;
break;
end;
end
Iteration must end when max(Y,H)<0.01
Thank you
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 5월 26일
Yes, that is what you programmed, that the iterations will end when that condition holds.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2013년 5월 26일
After the assignment to H, assign
U1 = U1t;
U2 = U2t;
Unless, that is, you need the U1 value to be unchanged if the iteration should stop. If that is the case, put those two statements after the "end" for the "if"

추가 답변 (2개)

Artur M. G. Lourenço
Artur M. G. Lourenço 2013년 5월 26일
Sorry if I misunderstood. It would be just that?
S12t=6+2*1i;
S01t=10+5*1i;
U1=110;
U2=110;
R12 = 16.2+24*1i;
U0i=115;
R01= 15.75+31.2*1i;
dx01=106.125;
dx12=81;
U20=10;
zoruu=0.01;
iteration_number = 0;
while true
iteration_number = iteration_number + 1;
fprintf('Starting iteration #%d\n', iteration_number);
dQ12=dx12*U2.^2*10.^-6;
S12i=S12t-complex(0,dQ12);
DS12 =((real(S12i).^2+imag(S12i).^2)/U2.^2)*R12;
S12ii=DS12+S12i;
S12e=S12ii-complex(0,dQ12);
S01i=S12e+S01t;
dQ01=dx01*U1.^2*10.^-6;
S01ii=S01i-complex(0,dQ01);
DS01=((real(S01ii).^2+imag(S01ii).^2)/U1.^2)*R01;
dQ01i=dx01*U0i.^2*10.^-6;
S01ii2=S01ii+DS01;
S01iii=S01ii2-complex(0,dQ01i);
dU01i=(real(S01ii2)*real(R01)+imag(S01ii2)*imag(R01))./U0i;
dU01ii=(real(S01ii2)*imag(R01)-imag(S01ii2)*real(R01))./U0i;
U1t=sqrt((U0i-dU01i).^2+dU01ii.^2);
dU12i=(real(S12ii)*real(R12)+imag(S12ii)*imag(R12))./U1t;
dU12ii=(real(S12ii)*imag(R12)-imag(S12ii)*real(R12))./U1t;
U2t=sqrt((U1t-dU12i).^2+dU12ii.^2);
Y=U1t-U1;
H=U2t-U2;
U1= U1t;
U2= U2t;
if max(Y,H)<zoruu;
break; end; end
  댓글 수: 1
Jan
Jan 2013년 5월 26일
Please learn how for format code - follow the "? Help" link. Thanks.

댓글을 달려면 로그인하십시오.


Light
Light 2013년 5월 26일
Thank you very much!! I put it wrong place :-)
  댓글 수: 3
Light
Light 2013년 5월 27일
편집: Light 2013년 5월 27일
Really? Walter Robinson Please tell me. Where can i put this (U1=U1t, U2=U2t)
Is that right??
....
....
Y=U1t-U1;
H=U2t-U2;
if max(Y,H)<zoruu; break; end;
U1= U1t;
U2= U2t; end
Artur M. G. Lourenço
Artur M. G. Lourenço 2013년 5월 27일
Y=U1t-U1;
H=U2t-U2;
U1= U1t;
U2= U2t;
if max(Y,H)<zoruu;
break; end; end

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Schedule Model Components에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by