I wrote this matlab code but it is not working I need help with it .It is to sol
ID: 2073212 • Letter: I
Question
I wrote this matlab code but it is not working I need help with it .It is to solve a problem similar to the one in the pictures.
a=400;
b=0;
i=75;
ra=0.26;
i2=154.5;
n=0;
while(Re[n]>0)
(Re[n]=(a-b)/i2-ra;
z=(a-b)/i;
Eb[n+1]=a-i*z;
n=n+1;
b=Eb[n+1];
end
Number of stages=n;
Rs1 = Re[0]-Re[1];
Rs2 = Re[1]-Re[2];
Rs3 = Re[2]-Re[3];
Explanation / Answer
%I have modified variable names according to given problem
Vt=400;
Eb=0;
i=75;
Ra=0.26;
i2=154.5;
n=1;
Eb(n)=0;
Re(n)=((Vt-Eb(n))/i2)-Ra;
while(Re(n)>0)
Eb(n+1)=Vt-(i*(Re(n)+Ra));
n=n+1;
Re(n)=((Vt-Eb(n))/i2)-Ra;
end
number_of_stages = n-1;
Rs1 = Re(1)-Re(2);
Rs2 = Re(2)-Re(3);
Rs3 = Re(3)-Re(4);
Rs4 = Re(4);
fprintf('%d,%d,%d,%d',Rs1,Rs2,Rs3,Rs4);