title: The size of the indicated variable or array appears to be changing with each loop iteration
body: <p>I tried to plot the <code>Hx</code> and <code>Hy</code> for the following Matlab script but, I got the following :</p>
  
  <p><code>Undefined function or variable 'HxR'</code> </p>
  
  <p>however, I have already defined it as <code>Hx=HxR+HxL</code> in my code. Matlab give the reason for this problem as(The size of the indicated variable or array appears to be changing with each loop iteration). Could anyone have any idea to help, I appreciate it </p>
  
  <pre><code>Ro=10.0;    % enclosing area radius
  To=pi/3;    % angle between sheets
  Uo=1.0;     
  y= 1.0;
  g = 10e-9;  % gap length  
  Uo = 1.0;   
  ro = 10.0;  
  to = pi/3;  % Interior angle
  
  
  m = 1;
  
  for x = -g/2:g/100:g/2
  
  SQP= sqrt((g+x).^2+y^2);
  
  
  if ( x&lt;= 0)
  
  HxL = (4*Uo*(SQP/Ro).^(-To/(pi+To))*(Ro*y*SQP)*(-1+(SQP/Ro)^(2*pi/(pi+To))*cos(pi*(-     pi+atan(y/(x+g)))/(pi+To))+(g+x).*(1+(SQP./Ro)^(2*pi/(pi+To))*sin(pi*(-pi+atan(y./(x+g)))./(pi+To))))/(Ro*(pi+To)*(g+x).* sqrt((1+y^2)./(g+x)^2)*(1+(SQP./Ro)^(4*pi/(pi+To)))-2*(SQP./Ro)^(2*pi/(pi+To))*cos((2*pi^2 + 2*atan(y./(g+x))./(pi+To)))));
       HyL= -(4*Uo*(SQP./Ro).^(-To/(pi+To))*(Ro*(g+x).*SQP)*(-1+(SQP./Ro)^(2*pi/(pi+To))*cos(pi*(-pi+atan(y./(x+g)))/(pi+To))+ y*(1+(SQP./Ro)^(2*pi/(pi+To))*sin(pi*(pi-atan(y./(x+g)))/(pi+To))))/(Ro*(pi+To)*(g+x).* sqrt((1+y^2)./(g+x)^2)*(1+(SQP./Ro)^(4*pi/(pi+To)))-2*(SQP/Ro)^(2*pi/(pi+To))));
  
  else
  
  SQM= sqrt((-g+x).^2+y^2);
  
  HxR = (4*Uo*(SQM/Ro).^(-1+(To/(pi+To)))*(y*(-1+(SQM./Ro)^(-2*pi/(-2*pi+To))*cos((pi*atan(y./(x-g))/(2*pi-To)))+(g-x)*(1+(SQM ./Ro)^(-2*pi./-2*(pi+To/2))*sin((pi*atan(y./(x-g)))/(2*pi-To)))))/(Ro*(2*pi-To).*(g-x).* sqrt((1+y^2)./(g-x)^2)* (1+(SQM/Ro)^(-4*pi/(-2*pi+To)))-2.*(SQM/Ro)^(-2*pi/(-2*pi+To))*cos((2*pi*atan(y./(-g+x))./(2*pi-To)))));
  HyR= (4*Uo*(SQM./Ro).^(-1+(pi/(2*pi-To)))*((g-x).*(-1+(SQM./Ro)^(-2*pi/(-2*pi+To))*cos((pi*atan(y./(x-g))/(2*pi-To)))-y*(1+(SQM./Ro)^(-2*pi/-2*(pi+To/2))*sin((pi*atan(y./(x-g)))/(2*pi-To)))))/(Ro*(2*pi-To)*(g-x).* sqrt((1+y^2)./(g-x)^2)*(1+(SQM./Ro)^(-4*pi/(-2*pi+To)))-2*(SQM./Ro)^(-2*pi/(-2*pi+To))*cos((2*pi*atan(y./(-g+x))/(2*pi-
  end
  
  Hx(m) = HxR + HxL;
  Hy(m) = HyR + HyL;
  
  m = m+1;
  end
  
  x = -g/2:g/100:g/2;
  
  figure
  plot(x,Hx)
  title('Hx')
  
  figure
  plot(y,Hy,'-r')
  title('Hy')
  </code></pre>