Azzera filtri
Azzera filtri

How to update new value in next iteration?

3 visualizzazioni (ultimi 30 giorni)
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 Commento
Walter Roberson
Walter Roberson il 26 Mag 2013
Yes, that is what you programmed, that the iterations will end when that condition holds.

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 26 Mag 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"

Più risposte (2)

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

Accedi per commentare.


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

Accedi per commentare.

Categorie

Scopri di più su Schedule Model Components in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by