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

📄 conv_computer.asv

📁 matlab实现卷积运算。非常高兴业大家分享此代码。
💻 ASV
字号:
% ------------------------------------------------------------------
% conv_computer.m
% Computer the convolution sum and the convolution integral program
% 运行脚本程序
% ------------------------------------------------------------------
close all
clear all
disp ( '   Welcome use conv_computer!' );
disp ( '   Please select the function you want to use:' );
disp ( '     0.Myself Convolution' );                   % 计算简单离散卷积
disp ( '     1.The Convolution Sum.' );                 % 计算离散卷积
disp ( '     2.The Convolution Integral.' );            % 计算连续卷积
disp ( '     3.The Intime Convolution' );               % 计算实时离散卷积
type = input ( '   Your selected number:  ' );          % 选择相应的程序
while ( type ~= 0 && type ~= 1 && type ~= 2 && type ~= 3 )
    type = input ( '   Please select number 0, 1, 2 or 3:  ' );
end;
switch ( type )
    case 0                                              % 计算简单离散卷积
        disp ( '   Myself Convolution' );
        x = input ( '     Please enter the input signals x = ' );   % 输入信号
        lx = length ( x );
        nx = [ 0 : lx - 1 ];
        figure (1);
        stem ( nx, x );
        title ( 'Input Signals x[n]' );
        xlabel ( 'n' );
        ylabel ( 'x[n]' );
        h = input ( '     Please enter the system h = ' );          % 系统
        lh = length ( h );
        nh = [ 0 : lh - 1 ];
        figure (2);
        stem ( nh, h );
        title ( 'System h[n]' );
        xlabel ( 'n' );
        ylabel ( 'h[n]' );
        [ y ] = self_conv ( x, h );                                 % 输出信号
        figure ( 3 );
        n = [ 0 : lx + lh - 2 ];
        stem ( n, y );
        title ( 'Onput Signals y[n] = x[n]*h[n]' );
        xlabel ( 'n' );
        ylabel ( 'y[n]' );
    case 1                                                  % 计算离散卷积
        disp ( '   The Convolution Sum' );
        disp ( '   Input Signals:' );                               % 输入信号
        n0 = input ( '     Please enter the beginning n0 = ' );
        nk = input ( '     Please enter the end nk = ' );
        nx = [ n0 : nk ];
        x = input ( '     Please enter the input signals ( e.g. sin ( nx ) ) x = ' );
        figure (1);
        stem ( nx, x );
        title ( 'Input Signals x[n]' );
        xlabel ( 'n' );
        ylabel ( 'x[n]' );
        disp ( '   System:' );                                      % 
        n0 = input ( '     Please enter the beginning n0 = ' );
        nk = input ( '     Please enter the end nk = ' );
        nh = [ n0 : nk ];
        h = input ( '     Please enter the system ( e.g. sin ( nh ) ) h = ' );
        figure (2);
        stem ( nh, h );
        title ( 'System h[n]' );
        xlabel ( 'n' );
        ylabel ( 'h[n]' );
        pause (1);
        figure (3);
        [ y, n ] = conv_sum ( x, nx, h, nh );
    case 2
        p = 0.01;
        disp ( '   The Convolution Integral' );
        disp ( '   Input Signals:' );
        t0 = input ( '     Please enter the beginning t0 = ' );
        tn = input ( '     Please enter the end tn = ' );
        tx = [ t0 : p : tn ];
        x = input ( '     Please enter the input signals ( e.g. sin ( tx ) ) x = ' );
        figure (1);
        plot ( tx, x );
        title ( 'Input Signals x(t)' );
        xlabel ( 't' );
        ylabel ( 'x(t)' );
        disp ( '   System:' );
        t0 = input ( '     Please enter the beginning t0 = ' );
        tn = input ( '     Please enter the end tn = ' );
        th = [ t0 : p : tn ];
        h = input ( '     Please enter the system ( e.g. sin ( th ) ) h = ' );
        figure (2);
        plot ( th, h );
        title ( 'System h(t)' );
        xlabel ( 't' );
        ylabel ( 'h(t)' );
        pause (1);
        figure (3);
        [ y, t ] = conv_integral ( x, tx, h, th, p );
    otherwise
        disp ( '   The Intime Convolution' );
        h = input ( '     Please enter the fixed system h = ' );
        disp ( '     Now begin to enter the discrete signal one by one from keyboard.' );
        [ y ] = conv_intime ( h );
end;

⌨️ 快捷键说明

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