title: Sweep / chirp signal ends at incorrect frequency
body: <p>I'm creating a sweep / chirp signal using matlab / octave and my ending signal seems to be ending at the wrong frequency.  How can I fix it so that the signal ends at the correct frequency.</p>
  
  <p>PS: I can't use the chirp command in  octave because I'm creating a chirp / sweep signal using a specific equation.</p>
  
  <p>Example code with simple equation. and plot of problem</p>
  
  <pre><code>%test sweep / chirp
  
  clear all,clc
  freq1=20; %start freq
  freq2=200; %end freq
  fs=44100;
  dur=1; %duration of signal in seconds
  
  t = linspace(0,2*pi,fs*dur);
  
  f=freq1:(freq2-freq1)/length(t):freq2-(freq2-freq1)/length(t); 
  %20:(200-20)/lenght(t) :200-(200-20)/length(t)
  
  data=sin(f.*t); %build signal
  data=(data/max(abs(data))*.8); %normalize signal
  wavwrite([data'] ,fs,32,strcat('/tmp/del.wav')); %export file
  plot(t,data)
  </code></pre>
  
  <p>PS: I'm using octave 3.8.1</p>
  
  <p><img src="https://i.stack.imgur.com/tlyyM.png" alt="enter image description here"></p>