title: MATLAB IF statement
body: <p>Im a new MATLAB user. Trying to initialize y to the calculated value in the if statement. However, when I try to plot y it says y not defined</p>
  
  <pre><code>function [y,xmax] = Alaw(x,A,ymax)
  
  if nargin&lt;3, ymax=1; end
  if nargin&lt;2, A=87.6; end
  
  
  xmax=max(abs(x)); 
  
      temp = ymax/A;
  if ((x &gt; 0) &amp; ( x &lt; temp ))
      y = (A * abs(x)) ./ (1 + log(A) ).*sign(x);
  end    
  
  if (x &gt; temp)
      y = ymax*( 1 + log(A*abs(x/ymax)) )./( 1+log(A) ).*sign(x);
  end
  
  
   fprintf('Plotting Data ...\n');
   hold on;
   figure;
   plot(y);
   xlabel('x-axis');
   ylabel('y-axis');
   title('  A LAW ');
  
   pause;
   fprintf('Writing the audio file ...\n');
   wavwrite(y, 22050, 'Alaw.wav');
  
  
   end
  </code></pre>