源程序:
fid=fopen('C:\Users\Pan\Documents\MATLAB\3.wma','r');
p1=fscanf(fid,'% f');
fclose(fid);
p2=filter([1 -0.68],1,p1);
x=fra(320,160,p2);
x=x(60,:);
s=x';
N=16;
p=N;
n=length(s);
for i=1:p
Rp(i,1)=sum(s(i+1:n).*s(1:n-i));
end
Rp=Rp(:)
Rp_0=s'*s;
Ep=zeros(p,1);
k=zeros(p,1);
a=zeros(p,p);
Ep_0=Rp_0;
k(1,1)=Rp(1,1)/Rp_0;
a(1,1)=k(1,1);
Ep(1,1)=(1-k(1,1)^2)*Ep_0;
if p>1
for i=2:p
k(i,1)=(Rp(i,1)-sum(a(1:i-1,i-1).*Rp(i-1:i-1:1)))/Ep(i-1,1);
a(i,i)=k(i,1);
Ep(i,1)=(1-k(i,1)^2)*Ep(i-1,1);
for j=1;i=1;
a(j,i)=a(j,i-1)-k(i,1)*a(i-j,i-1);
end
end
end
c=-a(:,p);
a1(1,1)=1.0;
for i=2:p+1
a1(1,i)=c(i-1,1);
end
仿真运行老是会出现这个错误提示:
Error using filter
Arguments must be single or double.
Error in Untitled4 (line 4)
p2=filter([1 -0.68],1,p1);
恳求求大神指教!!
亲,我想知道如何在matlab中确认参数的维数呢?还有就是能帮我看下下面这条语句是那里错了吗?
[s1,f1,t1] = specgram(MusicSource,N,N / 2,N);
[Xs1,Ys1] = size(s1);
for i = 1:Xs1
FTframe1(i) = s1(i,frame);
end
运行过程中总是会出现specgram调用错误,能说说specgram的函数格式吗?
就像Matlab是Matrix lab一样,在Matlab中操作对象都看成矩阵。
矩阵的维数用size求,比如[Xs1,Ys1] = size(s1);
specgram已经淘汰了,现在所用Matlab都用spectrogram
Syntax
S = spectrogram(x)
S = spectrogram(x,window)
S = spectrogram(x,window,noverlap)
S = spectrogram(x,window,noverlap,nfft)
S = spectrogram(x,window,noverlap,nfft,fs)
S = spectrogram(x,window,noverlap,F)
S = spectrogram(x,window,noverlap,F,fs)
[S,F,T] = spectrogram(...)
[S,F,T,P] = spectrogram(...)
看你想咋用。
希望这些对你有用。