zoukankan      html  css  js  c++  java
  • matlab lab

    
    
    
    clear all; close all, clc;
    % this clears your workspace, closes all figures, and clears command window
    
    % This script demonstrates how to use MATLAB to generate 
    % a simple signal plot. In this example, we construct
    % and plot a signal x(t)=exp(-t)sin(6*pi*t)u(t+1)
    
    % To graph a signal, the first step is to determine
    % the t-axis and the x-axis to plot
    % We can first decide the length of t-axis to plot
        t=[-2:0.01:3];   % "t" is from -2 to 3 in 0.01 increment
    % Then evalute the signal over the range of "t" to plot
    
    %x = exp(-t).*sin(6*pi*t).*ustep(t+1);
    %%1
    
    %x = triangle(t).*sin(6*pi*t);
    %%2
    
    x = exp(-t/2).*rect(t+1).*sin(12*pi*(t+1))+triangle(t-1).*sin(6*pi*(t-1));
    %%3
    
    figure(1); fig1=plot(t,x); % plot t vs x in figure 1
    set(fig1,'Linewidth',2); % choose a wider line-width
    xlabel('it t'); % use italic 't' to label t-axis
    ylabel('{f x}({it t })'); % use boldface 'x' to label x-axis
    title('{f x}_{
    m time domain}');
    
    % ustep.m implements the unit step function u(t)
    % rect.m implements the standard rectangular function rect(t)
    % triangle.m implements standard triangle function triangle(t)
    
    
    % Quadrature Amplitude Modulation
    clc; clear all; close all;
    
    fc = 40; % Carrier frequency in Hz
    fm1 = 2; % Modulating frequency in Hz
    fm2 = 5 % Modulating frequency in Hz
    Fs = 1000; % Sampling frequency in Hz
    
    t=0:1/Fs:1;
    m1=cos(2*pi*fm1*t)+2*cos(3*pi*fm1*t); % Message signal 1
    m2=cos(2*pi*fm2*t)+2*cos(5*pi*fm2*t); % Message signal 2
    
    c1=cos(2*pi*fc*t); % In-phase carrier signal
    c2=sin(2*pi*fc*t); % Quadrature-phase carrier signal
    
    % Modulation
    x1=m1.*c1; % Modulated signal 1
    x2=m2.*c2; % Modulated signal 2
    x=x1+x2;
    
    %Demodulation
    y = x.*cos(2*pi*fc*t);
    [num,den] = butter(5,2*fc/Fs); % IIR lowpass filter
    y = filtfilt(num,den,y)*2; % Demodulated signal
    
    
    z = x.*sin(2*pi*fc*t);
    [num,den] = butter(5,2*fc/Fs); % IIR lowpass filter
    z = filtfilt(num,den,z)*2; % Demodulated signal
    
    
    
    
    
    % plots
    figure(1),
    subplot(321); plot (t,m1)
    ylabel('Amplitude'); xlabel('Time');
    title('Message signal 1');
    %
    subplot(322); plot (t,m2)
    ylabel('Amplitude'); xlabel('Time');
    title('Message signal 2');
    %
    subplot(323); plot (t,c1)
    ylabel('Amplitude'); xlabel('Time');
    title('Carrier signal');
    %
    subplot(324); plot (t,x)
    ylabel('Amplitude'); xlabel('Time');
    title('QAM signal');
    
    subplot(325); plot (t,y)
    ylabel('Amplitude'); xlabel('Time');
    title('QAM demodulated signal 1');
    
    subplot(326); plot (t,z)
    ylabel('Amplitude'); xlabel('Time');
    title('QAM demodulated signal 2');
    
    
    
    透过泪水看到希望
  • 相关阅读:
    SpringBoot介绍
    linux运行jar以及vi
    linux文件命名
    数据库 mysql
    SSM框架-Spring
    SSM框架-mybatis
    SSM框架-SpringMVC
    设计模式-策略模式
    设计模式-单例模式
    Java多线程实现和JUC介绍
  • 原文地址:https://www.cnblogs.com/ronnielee/p/10489420.html
Copyright © 2011-2022 走看看