声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 964|回复: 4

[编程技巧] 大問題

[复制链接]
发表于 2008-11-20 21:06 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
程式
function [y] = 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=[x zeros(1,N-m)]; % 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)
[bo]??? Error using ==> horzcat
CAT arguments dimensions are not consistent.

Error in ==> my_ola_filter at 9
x=[x zeros(1,N-m)]; % preappend (M-1) zeros[/bo]
>>
如何解決????????
謝謝!!!!!

[ 本帖最后由 sigma665 于 2008-11-21 15:25 编辑 ]
回复
分享到:

使用道具 举报

发表于 2008-11-20 21:33 | 显示全部楼层

回复 楼主 tim2001 的帖子

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

[ 本帖最后由 sogooda 于 2008-11-20 21:34 编辑 ]
发表于 2008-11-20 21:42 | 显示全部楼层

回复 楼主 tim2001 的帖子

LZ是怎么调用my_ola_filter函数的?
发表于 2008-11-20 21:44 | 显示全部楼层
这句是不是也有问题?
Y(k,=circonvt(xk, h, N1); % recall circonvt function
 楼主| 发表于 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=[x zeros(1,N-length(x))];
n=[0:1:N-1];
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=[x1 zeros(1,N-length(x1))];
x2=[x2 zeros(1,N-length(x2))];
m=[0:1:N-1];
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 [y] = 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=[x zeros(1,N-m)]; % 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)

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

Error in ==> my_ola_filter at 9
x=[x zeros(1,N-m)]; % preappend (M-1) zeros[/bo]
>>
如何解決????
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-23 01:31 , Processed in 0.058562 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表