Hi dear friends,

I have problem with for loop. I don’t know my code doesn’t enter and repeat in loop.

```
using Plots
plotly()
Plots.PlotlyBackend()
currentcap=zeros(1,250001);
voltagecap=zeros(1,250001);
currentind=zeros(1,250001);
V= zeros(9,250004);
t_end = 250e-3;
dt = 1e-6;
t = 0:dt:t_end;
vp=20;
freq=50;
vs = vp*sin.(2*π*freq.* t')
L=1e-3;
R=1000;
C=1e-6;
Roff=10^10;
i=2;
c1=0;
c2=0;
for i=2:250001
c1=c1+1;
Y = [dt/L -dt/L 0 0 1 0 0 0 0
-dt/L dt/L+1/Roff -c/Roff -a/Roff 0 1 0 0 -1
0 -c/Roff (1/R)+(C/dt)+1/Roff -1/R-C/dt 0 -1 -1 0 0
0 -a/Roff -1/R-C/dt 1/R+C/dt+1/Roff 0 0 0 0 1 1
1 0 0 0 0 0 0 0 0
0 a -a 0 0 b 0 0 0
0 0 -c 0 0 0 e 0 0
0 0 0 f 0 0 0 g 0
0 -h 0 0 0 0 0 0 n];
x1=V[5,i]-currentind[1,i-1]; x2=currentind[1,i-1]-V[6,i]+V[9,i]; x3=V[6,i]-currentcap[1,i-1]; x4=currentcap[1,i]-V[8,i]-V[9,i] ;
I =[x1
x2
x3
x4
vp*sin.(2*π*freq.*t'[1,i])
0
0
0
0];
x=inv(Y)*I;
V[:,i]=x;
currentcap[1,i]=(C/dt)*(V[3,i]-V[3,i-1]-V[4,i]+V[4,i-1]);
voltagecap[1,i]=V[3,i]-V[4,i];
currentind[1,i]=(dt/L)*(V[1,i]-V[2,i]+V[1,i-1]-V[2,i-1])+currentind[1,i-1];
if V[2,i]-V[3,i]>0 || V[6,i]>0
a=1;b=0;
elseif V[6,i]<=0
a=0; b=1;
else
a=0; b=1;
end
if -V[3,i]>0 || V[7,i]>0
c=1; e=0;
elseif V[7,i]<=0
c=0; e=1
else
c=0; e=1;
end
if -V[4,i]>0 || V[8,i]>0
f=1; g=0;
elseif V[8,i]<=0
f=0; g=1
else
f=0; g=1;
end
if -V[4,i]-V[2,i]>0 || V[9,i]>0
h=1; n=0;
elseif V[9,i]<=0
h=0; n=1
else
h=0; n=1;
end
c2=c2+1;
end
voltagecap=voltagecap';
plot(t,voltagecap)
```