一个简单的RASTA matlab CODE

 

function y=rasta(x,fs,low,high)
% function y=rasta(x,fs) where x is the input data (rows of time data),
% and fs is the frame rate (sampling rate) in Hz.  This is a modified
% version of the original filter. Here the RASTA filter is approximated
% by a simple fourth order Butterworth bandpass filter.  See pages 50-51
% of my second IRC logbook for the derivation.
%
% Hermansky and Morgan, "RASTA Processing of Speech."  IEEE Transactions
% on Speech and Audio Processing.  vol. 2, no. 4, October 1994
%

% (c) 1998 Interval Research Corporation 
% Malcolm Slaney, January 30, 1996, Interval Research Corporation

if (nargin < 2); fs=100; end
if (nargin < 3); low=.9; end
if (nargin < 4); high=12.8; end

if (low == 0 & high == 0)   % Original Filter
 num = .1*[2 1 0 -1 -2];
 denum = [1 -.94];
else      % New fourth order
      % Butterworth BP filter
 w1=low/fs*2*pi;
 w2=high/fs*2*pi;
 theta=1;
 
 a=cos((w1+w2)/2)/cos((w2-w1)/2);
 k=cot((w2-w1)/2)*tan(theta/2);
 
 num = [1 0 -2 0 1];
 denum = [(1 + 2*2^(1/2)*k + 4*k^2) ...
   (-4*2^(1/2)*a*k - 16*a*k^2) ...
   (-2 + 8*k^2 + 16*a^2*k^2) ...
   (4*2^(1/2)*a*k - 16*a*k^2) ...
   (1 - 2*2^(1/2)*k + 4*k^2)];
 scale = denum(1);   % Scale by a(1) component
 num = num/scale;
 denum = denum/scale;
end

if (0)
 len = 1024;
 impulse = zeros(1,len);
 impulse(1) = 1;
 
 y=filter(num,denum,impulse);
 ym = abs(fft(y));
 ym=20*log10(ym);
 f=(0:(len-1))/len*fs;
 semilogx(f(1:len/2),ym(1:len/2));
 drawnow;
end

if (length(x) == size(x,1)*size(x,2))
 y = filter(num,denum,x,x(1)*[-1 -1 1 1]);
else
 y = zeros(size(x));
 for i=1:size(x,1)
  y(i,:) = filter(num,denum,x(i,:),x(i,1)*[-1 -1 1 1]/scale);
 end
end

Matlab code是一种用于编写和运行Matlab程序的编程语言。使用Matlab code,您可以实现各种功能,如运行加速、生成C代码、动态链接库分发、数据限制以及运行内存和算法量检查等。 Matlab Coder是一个强大的工具,通过它可以将Matlab代码转化为C代码,以实现更快的运行速度。您可以使用Matlab Coder来对Matlab代码进行优化和生成可移植的C代码,从而实现在不同平台上的部署和分发。 除了生成C代码外,Matlab Coder还可以生成Matlab动态链接库(MEX文件),以便在其他编程语言中调用Matlab函数。这使得Matlab代码可以与其他编程语言进行交互和集成,实现更复杂的功能和应用。 使用Matlab Coder还可以进行数据限制,即对输入数据进行约束和验证,确保输入数据满足预设的条件。例如,您可以定义输入数据的范围、类型和大小,并进行合法性检查,以避免错误和异常情况的发生。 此外,Matlab Coder还提供了运行内存和算法量检查功能,可以帮助您评估和优化代码的资源使用情况。您可以查看代码的内存消耗情况,并评估代码的计算复杂度和算法效率,以优化代码的性能和资源利用。 总之,Matlab code是一种用于编写和运行Matlab程序的编程语言,而Matlab Coder是一个强大的工具,可以将Matlab代码转化为C代码,实现更快的运行速度,并提供了许多功能和工具,以帮助您优化和生成可移植的代码。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [matlab coder分析](https://blog.csdn.net/qq_41886488/article/details/88649213)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值