Filter löschen
Filter löschen

How to update new value in next iteration?

3 Ansichten (letzte 30 Tage)
Light
Light am 26 Mai 2013
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 Kommentar
Walter Roberson
Walter Roberson am 26 Mai 2013
Yes, that is what you programmed, that the iterations will end when that condition holds.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 26 Mai 2013
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"

Weitere Antworten (2)

Artur M. G. Lourenço
Artur M. G. Lourenço am 26 Mai 2013
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 Kommentar
Jan
Jan am 26 Mai 2013
Please learn how for format code - follow the "? Help" link. Thanks.

Melden Sie sich an, um zu kommentieren.


Light
Light am 26 Mai 2013
Thank you very much!! I put it wrong place :-)
  3 Kommentare
Light
Light am 27 Mai 2013
Bearbeitet: Light am 27 Mai 2013
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 am 27 Mai 2013
Y=U1t-U1;
H=U2t-U2;
U1= U1t;
U2= U2t;
if max(Y,H)<zoruu;
break; end; end

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Schedule Model Components finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by