when i running my program it showing error like "Matrix dimensions must agree" .I tried for correcting but i cant correct. How i will rectify the error?

1 view (last 30 days)
Suchithra K S
Suchithra K S on 28 May 2019
Commented: Suchithra K S on 28 May 2019
The code is given below,
[y, Fs] = audioread('1calf.wav');
s = y(1:93098,:);
num=20;
n=512; %Number of FFT points
Tf=0.00475;
N=floor(Fs*Tf);
fn=24; %Number of mel filters
l=length(s); %total number of samples in speech
Ts=0.01; %Frame step in seconds
FrameStep=Fs*Ts; %Frame step in samples
a=1;
b=[1, -0.97]; %a and b are high pass filter coefficients
noFrames=floor(l/FrameStep); %Maximum no of frames in speech sample
FMatrix=zeros(noFrames-2, num); %Matrix to hold cepstral coefficients
lifter=1:num; %Lifter vector index
lifter=1+floor((num)/2)*(sin(lifter*pi/num));%raised sine lifter version
if mean(abs(s)) > 0.01
s=s/max(s); %Normalises to compensate for mic vol differences
end
for i=1:noFrames-2
frame=s((i-1)*FrameStep+1:(i-1)*FrameStep+N); %Holds individual frames
framef=filter(b,a,frame);%High pass pre-emphasis filter
F=framef.*hamming(N);%multiplies each frame with hamming window
FFTo=fft(F,N);%computes the fft
X(i, :)=FFTo;
end
filt_num = 45;
kcnst= 209; %nfft
%elephant sound features between 10hz to 10000hz
fmin= 10;
fmax= 10000;
%A1 and A2 areconstants and x is cochlea position K is cnst equal to 0.88.
greenwoodcnstK= 0.88;
greenwoodcnstA1= fmin/(1-greenwoodcnstK);
greenwoodcnstA2= log10((fmax/greenwoodcnstA1)+greenwoodcnstK);
i=0;
% greenwood frequency
for x = 0 : 0.01 : 1
i=i+1;
freq_grn(i) = (greenwoodcnstA1)*(10^(greenwoodcnstA2 * x)- (greenwoodcnstK));
end
%perceived frequency
for f= 10:1:500;
Fp(f)= (1/greenwoodcnstA2)*log10((f/greenwoodcnstA2)+greenwoodcnstK);
end
for i=1:1:filt_num
f(i)=floor((1024+1)*freq_grn(i)/Fs);
end;
% define triangular melbank
for j=2:1:filt_num-1
for i=1:1:kcnst
if i<f(j-1)
h(i,j-1)=0;
elseif f(j-1)<=i && f(j)>=i
h(i,j-1)=(i-f(j-1))/(f(j)-f(j-1));
elseif f(j)<i && f(j+1)>=i
h(i,j-1)=(f(j+1)-i)/(f(j+1)-f(j));
else
h(i,j-1)=0;
end;
end;
end;
figure(3);
plot(h);
for i=1:noFrames
for j=1:filt_num
bankans(i,j)=sum((X(i,:).*h(j,:)).^2);
end
end
logged=log10(bankans);
for i=1:NumFrames
gfcc(i,:)=dct2(logged(i,:));
end
%plotting the GFCC
figure
hold on
for i=1:NumFrames
plot(gfcc(i,1:45));
end
hold off
% save c5 mfcc
i= gfcc;
save i i
The error is like this,
Matrix dimensions must agree.
Error in greenwoodfrequencycepsco (line 80)
bankans(i,j)=sum((X(i,:).*h(j,:)).^2);
  4 Comments

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!