DSP using MATLAB example Example3.7

Source: Internet
Author: User

On the code:

X1 = rand (1,11); x2 = rand (1,11); n = 0:10;alpha = 2; beta = 3;  K = 0:500;              W = (pi/500) *k; % [0,PI] axis divided into 501 points.      X1 = x1 * (exp (-j*pi/500)). ^ (n ' *k);      % DTFT of x1x2 = x2 * (exp (-j*pi/500)). ^ (n ' *k);                % DTFT of x2x = Alpha * x1 + beta * x2;        % Linear combination of X1 & x2x = x * (exp (-j*pi/500)). ^ (n ' *k); % DTFT of xmagX1 = ABS (X1); angX1 = Angle (X1); RealX1 = Real (X1); imagX1 = Imag (X1); magX2 = ABS (X2); angX2 = Angle (X2); RealX2 = Real (X2);  imagX2 = Imag (X2); MAGX = ABS (X);  Angx = Angle (X);  Realx = Real (X);             IMAGX = Imag (X);%verificationx_check = alpha*x1 + beta*x2;              % Linear combination of X1 & x2error = MAX (ABS (X-x_check)); % difference%%--------------------------------------------------------------percent START X1 ' s mag ang real imag%%--- -----------------------------------------------------------figure (' Numbertitle ', ' off ', ' Name ', ' X1 its Magnitude and Angle, Real and imaginary Part '); set (GCF, ' Color ', ' white '); Subplot (2,2,1); Plot (W/PI,MAGX1);  Grid on; % axis ([ -2,2,0,15]); Title (' Magnitude part '), Xlabel (' Frequency in \pi units '); Ylabel (' Magnitude | X1| '); Subplot (2,2,3); Plot (W/pi, angx1/pi);  Grid on; % axis ([ -2,2,-1,1]); title (' Angle part '), Xlabel (' Frequency in \pi units '); Ylabel (' Radians/\pi '); subplot (' 2,2,2 '); Plot (W/pi, realX1); Grid On;title (' Real part '), Xlabel (' Frequency in \pi units '); Ylabel (' Real '); subplot (' 2,2,4 '); Plot (W/pi, imagX1); Grid On;title (' Imaginary part '), Xlabel (' Frequency in \pi units '); Ylabel (' imaginary '); percent--------------------------------------------------------------percent END X1 ' mag ang real imag %% --------------------------------------------------------------%% --------------------------------------------- -----------------percent START X2 ' s mag ang real imag%%--------------------------------------------------------------F Igure (' Numbertitle ', ' off ', ' Name ', ' X2 its Magnitude and Angle, Real and Imaginary part '); Set (GCF, ' Color ', ' white '); Subplot (2,2,1); Plot (W/PI,MAGX2);  Grid on; % axis ([ -2,2,0,15]); Title (' Magnitude part '), Xlabel (' Frequency in \pi units '); Ylabel (' Magnitude | X2| '); Subplot (2,2,3); Plot (W/pi, angx2/pi);  Grid on; % axis ([ -2,2,-1,1]); title (' Angle part '), Xlabel (' Frequency in \pi units '); Ylabel (' Radians/\pi '); subplot (' 2,2,2 '); Plot (W/pi, realX2); Grid On;title (' Real part '), Xlabel (' Frequency in \pi units '); Ylabel (' Real '); subplot (' 2,2,4 '); Plot (W/pi, imagX2); Grid On;title (' Imaginary part '), Xlabel (' Frequency in \pi units '); Ylabel (' imaginary '); percent--------------------------------------------------------------percent END X2 ' mag ang real imag %% --------------------------------------------------------------%% --------------------------------------------- -----------------percent START X ' s mag ang real imag%%--------------------------------------------------------------fi Gure (' Numbertitle ', ' off ', ' Name ', ' X its Magnitude and Angle, Real and Imaginary part '); set (GCF, ' Color ', ' White‘); Subplot (2,2,1); Plot (W/PI,MAGX);  Grid on; % axis ([ -2,2,0,15]); Title (' Magnitude part '), Xlabel (' Frequency in \pi units '); Ylabel (' Magnitude | X| '); Subplot (2,2,3); Plot (W/pi, angx/pi);  Grid on; % axis ([ -2,2,-1,1]); title (' Angle part '), Xlabel (' Frequency in \pi units '); Ylabel (' Radians/\pi '); subplot (' 2,2,2 '); Plot (W/pi, realx); Grid On;title (' Real part '), Xlabel (' Frequency in \pi units '); Ylabel (' Real '); subplot (' 2,2,4 '); Plot (W/pi, IMAGX); Grid On;title (' Imaginary part '), Xlabel (' Frequency in \pi units '); Ylabel (' imaginary '); percent--------------------------------------------------------------percent END X ' s mag ang real imag% % --------------------------------------------------------------

Results:

  

DSP using MATLAB example Example3.7

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.