Skip to main content
Bumped by Community user
i adjusted the `ind` index because MATLAB doesn't do X(0).
Source Link

I'm tring to code a STFT program in Matlab. I got results but I'm confused a bit. I have a audio signal of 900000 pts sampled at 1000Hz (15 min signal). I've taken fft with following parameters =>

  • hop size of H = 1400 pts
  • the window length M = H * 6

So, 5/6 of the window overlaps with the next one. The program runs for 637 iterations, as (637*1400 + M = 900200)

Now, I get a 637 pt vector with frequency in them. I should get a frequency vs time plot. But it only has 637 frequency bins, for a signal of 900000 time sample.

  1. How, can I find the change of frequency with Time (900000 sample) or 15 min?
  2. Moreover, how does changing the window length and overlap affect the outcome of STFT? The code is below.

%hop size L = 1400; %window length & Formation D = 6; %User Defined Parameter in Cooper's paper M = L*D; w = hanning(M, 'periodic'); %window formation k = 1; % k =index j = 1; % j =result vector index while k + M <= xlen %data chunk %x = x(k:1400); %window length & Window xw = x(k+1:k+M) .*w; %windowed signal %zero padding b = 5; %Zero Padding Factor 'b' xw = [xw; zeros(M*5,1)]; [nft,c] = size(xw); %plot(abs(fft(xw))) X = abs(fft(xw)); XF = X(1:length(X)/2); [q,ind] = max(XF); v(j) = ((fs/2)/(nft/2)) * ind;(ind-1); %convert Bin to frequency k = k+L; j = j+1; end figure(1); plot(v) axis([0 1400 0 100]) figure(2); %zoom version plot(v) 

I'm tring to code a STFT program in Matlab. I got results but I'm confused a bit. I have a audio signal of 900000 pts sampled at 1000Hz (15 min signal). I've taken fft with following parameters =>

  • hop size of H = 1400 pts
  • the window length M = H * 6

So, 5/6 of the window overlaps with the next one. The program runs for 637 iterations, as (637*1400 + M = 900200)

Now, I get a 637 pt vector with frequency in them. I should get a frequency vs time plot. But it only has 637 frequency bins, for a signal of 900000 time sample.

  1. How, can I find the change of frequency with Time (900000 sample) or 15 min?
  2. Moreover, how does changing the window length and overlap affect the outcome of STFT? The code is below.

%hop size L = 1400; %window length & Formation D = 6; %User Defined Parameter in Cooper's paper M = L*D; w = hanning(M, 'periodic'); %window formation k = 1; % k =index j = 1; % j =result vector index while k + M <= xlen %data chunk %x = x(k:1400); %window length & Window xw = x(k+1:k+M) .*w; %windowed signal %zero padding b = 5; %Zero Padding Factor 'b' xw = [xw; zeros(M*5,1)]; [nft,c] = size(xw); %plot(abs(fft(xw))) X = abs(fft(xw)); XF = X(1:length(X)/2); [q,ind] = max(XF); v(j) = ((fs/2)/(nft/2)) * ind; %convert Bin to frequency k = k+L; j = j+1; end figure(1); plot(v) axis([0 1400 0 100]) figure(2); %zoom version plot(v) 

I'm tring to code a STFT program in Matlab. I got results but I'm confused a bit. I have a audio signal of 900000 pts sampled at 1000Hz (15 min signal). I've taken fft with following parameters =>

  • hop size of H = 1400 pts
  • the window length M = H * 6

So, 5/6 of the window overlaps with the next one. The program runs for 637 iterations, as (637*1400 + M = 900200)

Now, I get a 637 pt vector with frequency in them. I should get a frequency vs time plot. But it only has 637 frequency bins, for a signal of 900000 time sample.

  1. How, can I find the change of frequency with Time (900000 sample) or 15 min?
  2. Moreover, how does changing the window length and overlap affect the outcome of STFT? The code is below.

%hop size L = 1400; %window length & Formation D = 6; %User Defined Parameter in Cooper's paper M = L*D; w = hanning(M, 'periodic'); %window formation k = 1; % k =index j = 1; % j =result vector index while k + M <= xlen %data chunk %x = x(k:1400); %window length & Window xw = x(k+1:k+M) .*w; %windowed signal %zero padding b = 5; %Zero Padding Factor 'b' xw = [xw; zeros(M*5,1)]; [nft,c] = size(xw); %plot(abs(fft(xw))) X = abs(fft(xw)); XF = X(1:length(X)/2); [q,ind] = max(XF); v(j) = ((fs/2)/(nft/2)) * (ind-1); %convert Bin to frequency k = k+L; j = j+1; end figure(1); plot(v) axis([0 1400 0 100]) figure(2); %zoom version plot(v) 
Bumped by Community user
Bumped by Community user
Bumped by Community user
Minor removal to avoid confusion
Source Link
Peter K.
  • 26.3k
  • 9
  • 49
  • 94

I'm tring to code a STFT program in Matlab. I got results but I'm confused a bit. I have a audio signal of 900000 pts sampled at 1000Hz (15 min signal). I've taken fft with following parameters =>

  • hop size of H = 1400 pts
  • the window length M = H(1400)*6 * 6

So, 5/6 of the window overlaps with the next one. The program runs for 637 iterations, as (637*1400 + M = 900200)

Now, I get a 637 pt vector with frequency in them. I should get a frequency vs time plot. But it only has 637 frequency bins, for a signal of 900000 time sample.

  1. How, can I find the change of frequency with Time (900000 sample) or 15 min?
  2. Moreover, how does changing the window length and overlap affect the outcome of STFT? The code is below.

%hop size L = 1400; %window length & Formation D = 6; %User Defined Parameter in Cooper's paper M = L*D; w = hanning(M, 'periodic'); %window formation k = 1; % k =index j = 1; % j =result vector index while k + M <= xlen %data chunk %x = x(k:1400); %window length & Window xw = x(k+1:k+M) .*w; %windowed signal %zero padding b = 5; %Zero Padding Factor 'b' xw = [xw; zeros(M*5,1)]; [nft,c] = size(xw); %plot(abs(fft(xw))) X = abs(fft(xw)); XF = X(1:length(X)/2); [q,ind] = max(XF); v(j) = ((fs/2)/(nft/2)) * ind; %convert Bin to frequency k = k+L; j = j+1; end figure(1); plot(v) axis([0 1400 0 100]) figure(2); %zoom version plot(v) 

I'm tring to code a STFT program in Matlab. I got results but I'm confused a bit. I have a audio signal of 900000 pts sampled at 1000Hz (15 min signal). I've taken fft with following parameters =>

  • hop size of H = 1400 pts
  • the window length M = H(1400)*6

So, 5/6 of the window overlaps with the next one. The program runs for 637 iterations, as (637*1400 + M = 900200)

Now, I get a 637 pt vector with frequency in them. I should get a frequency vs time plot. But it only has 637 frequency bins, for a signal of 900000 time sample.

  1. How, can I find the change of frequency with Time (900000 sample) or 15 min?
  2. Moreover, how does changing the window length and overlap affect the outcome of STFT? The code is below.

%hop size L = 1400; %window length & Formation D = 6; %User Defined Parameter in Cooper's paper M = L*D; w = hanning(M, 'periodic'); %window formation k = 1; % k =index j = 1; % j =result vector index while k + M <= xlen %data chunk %x = x(k:1400); %window length & Window xw = x(k+1:k+M) .*w; %windowed signal %zero padding b = 5; %Zero Padding Factor 'b' xw = [xw; zeros(M*5,1)]; [nft,c] = size(xw); %plot(abs(fft(xw))) X = abs(fft(xw)); XF = X(1:length(X)/2); [q,ind] = max(XF); v(j) = ((fs/2)/(nft/2)) * ind; %convert Bin to frequency k = k+L; j = j+1; end figure(1); plot(v) axis([0 1400 0 100]) figure(2); %zoom version plot(v) 

I'm tring to code a STFT program in Matlab. I got results but I'm confused a bit. I have a audio signal of 900000 pts sampled at 1000Hz (15 min signal). I've taken fft with following parameters =>

  • hop size of H = 1400 pts
  • the window length M = H * 6

So, 5/6 of the window overlaps with the next one. The program runs for 637 iterations, as (637*1400 + M = 900200)

Now, I get a 637 pt vector with frequency in them. I should get a frequency vs time plot. But it only has 637 frequency bins, for a signal of 900000 time sample.

  1. How, can I find the change of frequency with Time (900000 sample) or 15 min?
  2. Moreover, how does changing the window length and overlap affect the outcome of STFT? The code is below.

%hop size L = 1400; %window length & Formation D = 6; %User Defined Parameter in Cooper's paper M = L*D; w = hanning(M, 'periodic'); %window formation k = 1; % k =index j = 1; % j =result vector index while k + M <= xlen %data chunk %x = x(k:1400); %window length & Window xw = x(k+1:k+M) .*w; %windowed signal %zero padding b = 5; %Zero Padding Factor 'b' xw = [xw; zeros(M*5,1)]; [nft,c] = size(xw); %plot(abs(fft(xw))) X = abs(fft(xw)); XF = X(1:length(X)/2); [q,ind] = max(XF); v(j) = ((fs/2)/(nft/2)) * ind; %convert Bin to frequency k = k+L; j = j+1; end figure(1); plot(v) axis([0 1400 0 100]) figure(2); %zoom version plot(v) 
Attempt to fix formatting... which appears to be broken still in the preview?!?
Source Link
Peter K.
  • 26.3k
  • 9
  • 49
  • 94
  • hop size of H = 1400 pts

    hop size of H = 1400 pts
  • the window length M = H(1400)*6

    the window length M = H(1400)*6

So, 5/6 of the window overlaps with the next one. The program runs for 637 interationiterations, as (637*1400 + M = 900200)

  1. How, can I find the change of frequency with Time (900000 sample) or 15 min?
  2. Moreover, how does changing the window length and overlap affect the outcome of STFT? Thanks The Codecode is below:.

%hop size L = 1400;

%window length & Formation D = 6; %User Defined Parameter in Cooper's paper M = L*D; w = hanning(M, 'periodic'); %window formation k = 1; % k =index j = 1; % j =result vector index while k + M <= xlen %data chunk %x = x(k:1400); %window length & Window xw = x(k+1:k+M) .*w; %windowed signal %zero padding b = 5; %Zero Padding Factor 'b' xw = [xw; zeros(M*5,1)]; [nft,c] = size(xw); %plot(abs(fft(xw))) X = abs(fft(xw)); XF = X(1:length(X)/2); [q,ind] = max(XF); v(j) = ((fs/2)/(nft/2)) * ind; %convert Bin to frequency k = k+L; j = j+1; end figure(1); plot(v) axis([0 1400 0 100]) figure(2); %zoom version plot(v) 

%hop size L = 1400; %window length & Formation D = 6; %User Defined Parameter in Cooper's paper M = L*D; w = hanning(M, 'periodic'); %window formation k = 1; % k =index j = 1; % j =result vector index while k + M <= xlen %data chunk %x = x(k:1400); %window length & Window xw = x(k+1:k+M) .*w; %windowed signal %zero padding b = 5; %Zero Padding Factor 'b' xw = [xw; zeros(M*5,1)]; [nft,c] = size(xw); %plot(abs(fft(xw))) X = abs(fft(xw)); XF = X(1:length(X)/2); [q,ind] = max(XF); v(j) = ((fs/2)/(nft/2)) * ind; %convert Bin to frequency k = k+L; j = j+1; end figure(1); plot(v) axis([0 1400 0 100]) figure(2); %zoom version plot(v) 
  • hop size of H = 1400 pts

  • the window length M = H(1400)*6

So, 5/6 of the window overlaps with the next one. The program runs for 637 interation, as (637*1400 + M = 900200)

  1. How, can I find the change of frequency with Time (900000 sample) or 15 min?
  2. Moreover, how does changing the window length and overlap affect the outcome of STFT? Thanks The Code is below:

%hop size L = 1400;

%window length & Formation D = 6; %User Defined Parameter in Cooper's paper M = L*D; w = hanning(M, 'periodic'); %window formation k = 1; % k =index j = 1; % j =result vector index while k + M <= xlen %data chunk %x = x(k:1400); %window length & Window xw = x(k+1:k+M) .*w; %windowed signal %zero padding b = 5; %Zero Padding Factor 'b' xw = [xw; zeros(M*5,1)]; [nft,c] = size(xw); %plot(abs(fft(xw))) X = abs(fft(xw)); XF = X(1:length(X)/2); [q,ind] = max(XF); v(j) = ((fs/2)/(nft/2)) * ind; %convert Bin to frequency k = k+L; j = j+1; end figure(1); plot(v) axis([0 1400 0 100]) figure(2); %zoom version plot(v) 
  • hop size of H = 1400 pts
  • the window length M = H(1400)*6

So, 5/6 of the window overlaps with the next one. The program runs for 637 iterations, as (637*1400 + M = 900200)

  1. How, can I find the change of frequency with Time (900000 sample) or 15 min?
  2. Moreover, how does changing the window length and overlap affect the outcome of STFT? The code is below.

%hop size L = 1400; %window length & Formation D = 6; %User Defined Parameter in Cooper's paper M = L*D; w = hanning(M, 'periodic'); %window formation k = 1; % k =index j = 1; % j =result vector index while k + M <= xlen %data chunk %x = x(k:1400); %window length & Window xw = x(k+1:k+M) .*w; %windowed signal %zero padding b = 5; %Zero Padding Factor 'b' xw = [xw; zeros(M*5,1)]; [nft,c] = size(xw); %plot(abs(fft(xw))) X = abs(fft(xw)); XF = X(1:length(X)/2); [q,ind] = max(XF); v(j) = ((fs/2)/(nft/2)) * ind; %convert Bin to frequency k = k+L; j = j+1; end figure(1); plot(v) axis([0 1400 0 100]) figure(2); %zoom version plot(v) 
added 608 characters in body
Source Link
Rio1210
  • 113
  • 8
Loading
added 608 characters in body
Source Link
Rio1210
  • 113
  • 8
Loading
edited body
Source Link
Rio1210
  • 113
  • 8
Loading
Source Link
Rio1210
  • 113
  • 8
Loading