Signals and Systems Profs. Byron Yu and Pulkit Grover Fall Homework 1

Similar documents
Laboratory 1 Introduction to MATLAB for Signals and Systems

Grace days can not be used for this assignment

Matlab Tutorial. Get familiar with MATLAB by using tutorials and demos found in MATLAB. You can click Start MATLAB Demos to start the help screen.

EE 301 Signals & Systems I MATLAB Tutorial with Questions

AMS 27L LAB #2 Winter 2009

ECE 3793 Matlab Project 1

EE 301 Lab 1 Introduction to MATLAB

A Guide to Using Some Basic MATLAB Functions

MATLAB/Octave Tutorial

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

12 whereas if I terminate the expression with a semicolon, the printed output is suppressed.

LAB 1: Introduction to MATLAB Summer 2011

EE3TP4: Signals and Systems Lab 1: Introduction to Matlab Tim Davidson Ext Objective. Report. Introduction to Matlab

How to learn MATLAB? Some predefined variables

EE-3221 MATLAB INTRODUCTION

Basic Simulation Lab with MATLAB

1 Introduction to Matlab

STAT/MATH 395 A - PROBABILITY II UW Winter Quarter Matlab Tutorial

MATH 2221A Mathematics Laboratory II

An Introduction to MATLAB II

Eric W. Hansen. The basic data type is a matrix This is the basic paradigm for computation with MATLAB, and the key to its power. Here s an example:

1. Register an account on: using your Oxford address

PART 1 PROGRAMMING WITH MATHLAB

MATLAB TUTORIAL WORKSHEET

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures

Stokes Modelling Workshop

EE 216 Experiment 1. MATLAB Structure and Use

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

Introduction to MATLAB LAB 1

ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah)

Lab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013

EGR 102 Introduction to Engineering Modeling. Lab 05A Managing Data

The value of f(t) at t = 0 is the first element of the vector and is obtained by

Dr Richard Greenaway

Introduction to MatLab. Introduction to MatLab K. Craig 1

MATLAB Project: Getting Started with MATLAB

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain

EEE161 Applied Electromagnetics Laboratory 1

Complex Dynamic Systems

George Mason University Signals and Systems I Spring 2016

MAT 275 Laboratory 1 Introduction to MATLAB

Introduction to GNU-Octave

Mechanical Engineering Department Second Year (2015)

Classes 7-8 (4 hours). Graphics in Matlab.

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB?

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment

MATLAB Project: Getting Started with MATLAB

2.0 MATLAB Fundamentals

MATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab

MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras

MATLAB. Input/Output. CS101 lec

AN INTRODUCTION TO MATLAB

MATLAB Tutorial EE351M DSP. Created: Thursday Jan 25, 2007 Rayyan Jaber. Modified by: Kitaek Bae. Outline

This is a basic tutorial for the MATLAB program which is a high-performance language for technical computing for platforms:

An Introduction to Numerical Methods

Homework 1 Description CmpE 362 Spring Instructor : Fatih Alagoz Teaching Assistant : Yekta Said Can Due: 3 March, 23:59, sharp

ELEN E3084: Signals and Systems Lab Lab II: Introduction to Matlab (Part II) and Elementary Signals

1-- Pre-Lab The Pre-Lab this first week is short and straightforward. Make sure that you read through the information below prior to coming to lab.

Writing MATLAB Programs

Getting Started with MATLAB

Lecture 2: Variables, Vectors and Matrices in MATLAB

CS/NEUR125 Brains, Minds, and Machines. Due: Wednesday, March 8

Matlab Introduction. Scalar Variables and Arithmetic Operators

Getting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text

MATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix.

A Very Brief Introduction to Matlab

Introduction to MATLAB

Basics: vectors, matrices, arrays

A Quick Tutorial on MATLAB. Zeeshan Ali

Math 375 Natalia Vladimirova (many ideas, examples, and excersises are borrowed from Profs. Monika Nitsche, Richard Allen, and Stephen Lau)

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation

Fall 2014 MAT 375 Numerical Methods. Introduction to Programming using MATLAB

Introduction to MATLAB programming: Fundamentals

PC-MATLAB PRIMER. This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens.

MATLAB Tutorial. Digital Signal Processing. Course Details. Topics. MATLAB Environment. Introduction. Digital Signal Processing (DSP)

Introduction to MATLAB

ECE 3793 Matlab Project 2

Introduction to Matlab to Accompany Linear Algebra. Douglas Hundley Department of Mathematics and Statistics Whitman College

ENGR Fall Exam 1

Matlab Tutorial, CDS

MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY

Introduction to Matlab

Lab 1 Intro to MATLAB and FreeMat

Practical 4: The Integrate & Fire neuron

Assignment 02 (Due: Monday, February 1, 2016)

Laboratory 1 Octave Tutorial

A very brief Matlab introduction

Lab 1 Introduction to MATLAB and Scripts

ARRAY VARIABLES (ROW VECTORS)

Computer Project: Getting Started with MATLAB

Fall 2015 Math 337. Basic MatLab

What is MATLAB and howtostart it up?

EE 350. Continuous-Time Linear Systems. Recitation 1. 1

Course Layout. Go to follow instr. Accessible within campus (only for the first download)

CSE/NEUBEH 528 Homework 0: Introduction to Matlab

A Brief Introduction to MATLAB

MATLAB Fundamentals. Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University

Introduction to Matlab

A General Introduction to Matlab

Transcription:

18-290 Signals and Systems Profs. Byron Yu and Pulkit Grover Fall 2018 Homework 1 This homework is due in class on Thursday, September 6, 9:00am. Instructions Solve all non-matlab problems using only paper and pencil, without resorting to MATLAB or a computer. Please show all necessary steps to get the final answer. For MATLAB problems, include all code written to generate solutions. Ask any questions using the Q&A Board on Piazza, rather than emailing the course staff. Remember to label your axes and title your plots. Please submit Part One and Part Two on separate papers. Make sure each part is labeled with your name and AndrewID and separately stapled. Part One 1. (8 points) Consider the DT signal given by the algorithm: x[0] = 1 x[1] = 2 (a) Plot the signal x[n] for 0 n 11. x[n] = x[n 1] x[n 2] (b) Determine if the signal is periodic, and if so find its fundamental period. 2. (8 points) Consider the CT signal given by the fomula: (a) Plot the signal x(t) for 3 t 3. x(t) = 2 cos 2 (2πt/3) (b) Determine if the signal is periodic, and if so find its fundamental period.

2 Homework 1 3. (12 points) Determine if each of the following signals is periodic and, if so, find its fundamental period: (a) x(t) = sin 2 (2πt) (b) x(t) = e t cos(2πt) (c) x(t) = cos( 2π 3 t) + sin( π 2 t) (d) x(t) = cos(2πt) + cos( 2πt) 4. (10 points) (a) Consider the following DT signal: x[n] = {( 1 2) n 0 n 20 0 otherwise Determine the total energy and average power of x[n]. (b) Consider the following CT signal: 3t 0 t 5 x(t) = 15 5 < t 10 0 otherwise Determine the total energy and average power of x(t). 5. (12 points) Decompose the following signals into their odd and even components. Simplify your answer to the simplest expression: (a) x(t) = 10t 5 + 4t 4 t 3 t 2 1 (b) x(t) = 1 + t cos(t) + t 3 sin 2 (t) + t 4 cos(2t) sin(2t) (c) x[n] = cos(n) + sin(2n) + ( 1) n + ( 1) n sin( π 7 n) (d) x(t) = sin(3t) sin(2t) sin(t) (Hint: sin( x) = sin(x))

Homework 1 3 Part Two (Separate Paper) 6. (10 points) A pulse x(t) is defined by: x(t) = (a) Determine the total energy of x(t). { A cos(ωt) sin(ωt) 0 t T 0 otherwise (b) A differentiator is applied to x(t), defined by: y(t) = d dt x(t) Determine the resulting output y(t) of the differentiator. energy of y(t). Determine the total 7. (10 points) MATLAB Commands Please download MATLAB from the following website, which also provides instructions on how to do so. ECE students can choose to install the standalone edition in order to use MATLAB off campus. http://www.cmu.edu/computing/software/all/matlab/index.html When you start MATLAB, there are two windows to note: a workspace, which contains the current variables; a command window, which allows for the input of commands. When MATLAB is first started, both should be empty except for the command window prompt. >> You can create variables like in other programming languages: >> a = 2 You will note that the variable a now appears in the workspace. Once you have created variables, they will be saved in the workspace and you can use them in your new commands without having to define them again. Square brackets are used to create matrices. Columns are separated by spaces (or commas), and rows are separated by semicolons. Try the following commands in your MATLAB command window. To get information about any command, you can type help <name of the command>. >> b = [1 3 5] >> c = [1; 3; 4] >> d = [1 2 3; 5 6 7]

4 Homework 1 Try the following MATLAB operators: >> b*c >> b+b >> b+c >> d*c Note that if the dimensions do not agree, you cannot use certain operators. MATLAB has a large library of commands that help to manipulate your matrices. Try the following commands, and briefly explain what each of the commands do. Note that MATLAB indexing starts at 1, rather than 0 in many other programming languages. >> a = zeros (3, 4) >> b = ones (2, 5) >> c = eye (4) >> d = size (a) >> abs ([ -5, 3]) >> ceil (3.4) >> help floor >> e = [2:3:10] >> f = e >> g = e (2) >> h = cos (pi /2) >> k = exp (1.0) >> ex1 = linspace (1, 5, 4) >> ex1 = [ ex1 ; ex1 *2] >> n = ex1 (1, 2) >> p = ex1 (1, :) >> m = ex1 (1, 2: end ) >> q = [p m] >> cmplx = 3-2 i >> real ( cmplx ) >> imag ( cmplx ) >> abs ( cmplx ) >> angle ( cmplx ) >> 5^2 >> 3 == 3 >> 3 == 2 >> 3 ~= 1 >> whos >> clear a b

Homework 1 5 There are many other built-in functions in MATLAB. MATLAB has excellent documentation, so there are plenty of online resources for helping you find the functions you need. 8. (10 points) MATLAB Plots Now we will get to one of the powerful tools of MATLAB: plots. In order to use the plot function, you need a vector of values for the x-axis and one for the y-axis. You can use plot(x, y) to create a continuous line plot. >> x = [ -2:2] >> y = [1 4 4 7 3] >> plot (x, y) You can instead use stem(x, y) to plot discrete points in a stem plot. >> stem (x, y) Now, use these tools to make the following plots. Make sure to title your plots and label the axes. In order to do so, try help xlabel, help ylabel, and help title for instructions. (a) Odd component of y as both a continuous line plot and a discrete stem plot. (b) Even component of y as both a continuous line plot and a discrete stem plot. 9. (10 points) Matlab Functions A square wave, which is also called a pulse wave, is a periodic function that alternates between two values. The duty cycle is the percent of the period in which the signal is at its maximum value. The figure below shows a 1 Hz square wave with equal duration at the maximum value +1 and minimum value 0. So, its duty cycle is 50%. Now use the functions you examined in question 8 and write your own square wave generator. The specifics are:

6 Homework 1 The output variable mywave should be a square wave that has a fixed frequency of 1 Hz and alternates between 1 and 0. The signal lasts for 3 seconds. The input variable dutycycle ranges from 0 to 100 and it controls the duration of the maximum value, i.e. the fraction of time for which the signal is at its maximum value, expressed as a percentage. To define a function in Matlab, click on the yellow plus sign on the top left corner of the Matlab interface and type in the code below. function mywave = WaveGenerator ( dutycycle ) % your code here end Then save and name the.m file the same name as the function name under your current working directory. That is, you should save your script as WaveGenerator.m. In your submission, provide the code for this function. A hint for this problem is to use zeros and ones command. First, lets look at the first 0.5 seconds with a 0.01 second interval. That is, lets look at the value of the square wave plotted above at time points 0.01, 0.02,..., 0.5. The amplitude at these time points are always 1. So, to get the first half period of a square wave, use the command as follows: posvalue = ones (1,50); posvalue is a 1 50 vector that represents the first 0.5 seconds of the wave. Similarly, we can use zeros to generate the other half period of the wave. Then, concatenate two parts together to get a 1 100 vector for the whole period. Last, repmat function (for more information, use help repmat) allows you to repeat one period multiple times. In order to generate signals with different duty cycles, you only need to change the number of 1s and 0s. 10. (9 points) Put it all together Now, it is time to use your wavegenerator and the functions you learned from question 9 and plot a pulse wave function with 50% duty cycle and 85% duty cycle. To give you an example, the code below plots the 20% duty cycle square wave. t = 0.01:0.01:3; y = WaveGenerator (20); plot (t,y) title ( 20% duty cycle square wave ) xlabel ( Time (s) ) ylabel ( Amplitude )

Homework 1 7 In your submission, you only need to show the two plots for 50% and 85% duty cycle. If you can generate plots that look like the figure above, you have already finished your first 18290 homework! Yeah! But if you are a perfectionist, you can try command axis or adjust LineWidth for plot to make the plot prettier. 11. (1 point) How many hours did this homework take?