tim2001 发表于 2008-11-20 21:06

大問題

程式
function = my_ola_filter(x, h, N) %function of overlap add method
% x=input sequence
% h=impulse response
% N=blocksize
Lenx = length(x); M= length(h);% length of x & lenght of h
N1 = N+M-1;
m=rem(Lenx,N); %find remainder
if m~=0
x=; % preappend (M-1) zeros
K=floor(Lenx/N)+1; % number of blocks
else
x=x;K=floor(Lenx/N);
end

ytemp=zeros(1, N1-N);
n1=1; n2=N;

for k=1:K %convolution with succesive blocks
xk=x(n1:n2);
Y(k,=circonvt(xk, h, N1); % recall circonvt function
for i=1:N1-N
Y(k,i)=Y(k,i)+ytemp(i);
ytemp(i)=Y(k,i+N);
end
y(n1:n2)=Y(k,1:N);
n1=n1+N; n2=n2+N;
end
我用->
>> y=my_ola_filter(x, h, N)
??? Error using ==> horzcat
CAT arguments dimensions are not consistent.

Error in ==> my_ola_filter at 9
x=; % preappend (M-1) zeros
>>
如何解決????????
謝謝!!!!!

[ 本帖最后由 sigma665 于 2008-11-21 15:25 编辑 ]

sogooda 发表于 2008-11-20 21:33

回复 楼主 tim2001 的帖子

你的程序背景不懂,建议楼主先看看本版的精华帖子吧。包括但不限于你现在遇到的很多问题都可以找到答案的。
还有就是,楼主下次发帖子注意使用恰当的标题。

[ 本帖最后由 sogooda 于 2008-11-20 21:34 编辑 ]

ch_j1985 发表于 2008-11-20 21:42

回复 楼主 tim2001 的帖子

LZ是怎么调用my_ola_filter函数的?

ch_j1985 发表于 2008-11-20 21:44

这句是不是也有问题?
Y(k,=circonvt(xk, h, N1); % recall circonvt function

tim2001 发表于 2008-11-21 07:58

不好意思
完整的CODE是這樣
Function (1)
function y=cirshftt(x,m,N) % function of circular shift of m samples wrt size N in sequence x
% x=input sequence of length <= N
% m=sample shift
% N=size of circular buffer
if length(x)>N% check for length of x
   error('N must be >= the length of x')
end
x=;
n=;
n=mod(n-m,N);
y=x(n+1);

Function (2)
function y=circonvt(x1,x2,N) % function of N-point circular convolution between x1 and x2
% x1=input sequence of length N1 <= N
% x2=input sequence of length N2 <= N
% N=size of circular buffer
if length(x1)>N % check for length of x1
   error('N must be >= the length of x1')
end
if length(x2)>N % check for length of x2
   error('N must be >= the length of x2')
end
x1=;
x2=;
m=;
x2=x2(mod(-m,N)+1);
H=zeros(N,N);
for n=1:1:N
    H(n,:)=cirshftt(x2,n-1,N); % using cirshftt function
end
y=x1*H';

Function (3)
function = my_ola_filter(x, h, N) %function of overlap add method
% x=input sequence
% h=impulse response
% N=blocksize
Lenx = length(x); M= length(h);% length of x & lenght of h
N1 = N+M-1;
m=rem(Lenx,N); %find remainder
if m~=0
   x=; % preappend (M-1) zeros
   K=floor(Lenx/N)+1;% number of blocks
else
    x=x;K=floor(Lenx/N);
end
ytemp=zeros(1, N1-N);
n1=1; n2=N;
for k=1:K%convolution with succesive blocks
    xk=x(n1:n2);
    Y(k,:)=circonvt(xk, h, N1); % recall circonvt function
    for i=1:N1-N
      Y(k,i)=Y(k,i)+ytemp(i);
      ytemp(i)=Y(k,i+N);
    end
y(n1:n2)=Y(k,1:N);
n1=n1+N; n2=n2+N;
end

在M FILE 中有了這三條FUNCTION,
當我用FUNCTION 3時候
N=XXXXX<-----數字
>> y=my_ola_filter(x, h, N)

之後出現了
??? Error using ==> horzcat
CAT arguments dimensions are not consistent.

Error in ==> my_ola_filter at 9
x=; % preappend (M-1) zeros
>>
如何解決????
页: [1]
查看完整版本: 大問題