⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 converr.m

📁 很多matlab的源代码
💻 M
字号:

% ADSP Toolbox: Version 2.0 
% For use with "Analog and Digital Signal Processing", 2nd Ed.
% Published by PWS Publishing Co.
%
% Ashok Ambardar, EE Dept. MTU, Houghton, MI 49931, USA
% http://www.ee.mtu/faculty/akambard.html
% e-mail: akambard@mtu.edu
% Copyright (c) 1998


% CONVERR Relative energy error in the conv of two rectangular pulses.
%
%	CONVERR is a sample script m-file 

tol=0.05;            %Required relative error
d=10*tol;n=3;        %Starting error (a value > tol) and n (small)
nn=[]; dd=[];        %Used to store n and d for later plotting
x1=ones(1,n);y1=x1;  %two signals (same in this example)
z1=conv(x1,y1);      %Their convolution
e1=sum(z1.*z1);      %Starting energy in convolution
while d>tol          %Start of loop
 n=n+1;nn=[nn n];    %Augment n by 1 and store
 x2=ones(1,n);y2=x2; %Resample x & y (here y=x)
 z2=conv(x2,x2);     %Compute convolution
 e2=sum(z2.*z2);     %Energy in the new convolution
 d=abs(e1-e2)/e1;    %Relative error
 dd=[dd d];          %Store relative error
 e1=e2;              %Energy to be compared in next iteration
end                  %End of loop
disp([n;d])          %Display result

plot(nn,100*dd),grid,title('Relative error(%) vs number n of samples'),pause

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -