HFCC, Hello I have problem with code below

조회 수: 2 (최근 30일)
Michalina Stocka
Michalina Stocka 2020년 5월 19일
댓글: Rena Berman 2020년 10월 12일
My topic of project is: Analysis of HFCC parameter variability as a function of time for a given signal
I have problem with fft of z(n,t)
Subscripted assignment dimension mismatch.
Error in projekthfcc (line 57)
widmo(t,:) = fft(z(t,:),Nfft);
close all;
clear all;
[s,fp]=audioread('sygnal.wav');
N=length(s);
x=decimate(s,4);
Nx = length(x);
tx = (0:Nx-1)/fp;
%Preemfaza
N = length(x);
y=x(1);
for i=2:N
y(i)=x(i)-0.95*x(i-1);
end
fpr = fp/4;
figure(1)
plot(tx,x);
Ny = length(y);
ty = (0:Ny-1)/fpr;
%t = 0:1/fpr:(length(x)-1)/fpr;
figure(2)
plot(y);
ylabel('Badany sygnal po 4 krotnej decymacji');
xlabel('Czas[s]');
Nr = 25; %frame [ms]
Ns = 10; %step frame [ms]
nr = (Nr*0.001)*fpr; %rame [sample]
ns = (Ns*0.001)*fpr; %step frame [sample]
T = floor((Ny - nr - 1)/ns); %number of frames
Nfft = 2^nextpow2(nr);
N21 = Nfft/2+1;
z1 = zeros(length(0:T-1), length(0:nr-1));
z = zeros(length(0:T-1), length(0:nr-1));
for n = 1:nr
for t = 1:T
z1(t,n) = y(t*ns+n); % framing
z(t,n) = y(t*ns+n) * w(n,nr);% z1 * hamming windows
end
end
widmo = zeros(length(0:T-1), length(0:nr-1));
for t = 1:T
widmo(t,:) = fft(z(t,:),Nfft);
widmo1(t,:) = pow(abs(fft(widmo(t,:),2)));
end
function [ out ] = w( n, Nr )
if n < 1 || n > Nr
out = 0;
return;
end
out = 0.54 - 0.46*cos(2*pi*(n-1)/Nr-1);
end
  댓글 수: 4
Rik
Rik 2020년 8월 27일
편집: Rik 2020년 8월 27일
Why did you edit away your question? That is really rude. And pointless, as it can be restored again, as you could already see.
Rena Berman
Rena Berman 2020년 10월 12일
(Answers Dev) Restored edit

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2020년 5월 19일
Nfft = 2^nextpow2(nr);
So Nfft will be at least as large as nr, and often larger.
widmo = zeros(length(0:T-1), length(0:nr-1));
length(0:nr-1) is (nr-1) plus 1 for the 0, for a total of nr . So widmo has nr columns.
widmo(t,:) = fft(z(t,:),Nfft);
fft() with Nfft specified tells fft to use Nfft points. We established that Nfft is typically larger than nr, so the fft() would typically produce a vector larger than nr. But you are trying to store it in a row vector that has exactly nr columns.
  댓글 수: 3
Rik
Rik 2020년 7월 1일
Deleted comment recovered from Google cache:
Thank you for your answer.
I change this part of code:
widmo = zeros(length(0:T-1), length(0:Nfft-1));
for t = 1:T
widmo(t,:) = power(abs(fft(z(t,:),Nfft)),2);
end
and there is no error now, but I'm not sure if this is the correct version. The formula for fft is pictured below.
l - frequency indicator
L - number of spectrum bands
Rik
Rik 2020년 7월 1일
Deleted comment recovered from Google cache:
so "widmo" should be a matrix of what dimensions? and how can I determine the value of "L"? Sorry, maybe there are simple things, but I am a beginner in this ground :/

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Transforms에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by