signals & systems lab lab notes #3 - university of...

29
Signals & Systems Lab Lab Notes #3

Upload: others

Post on 21-Mar-2021

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print

Signals & Systems Lab

Lab Notes #3

Page 2: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 3: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 4: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print

𝑖

𝑛

𝑖=1

=𝑛 𝑛 + 1

2

Page 5: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 6: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print

function runfac=factorial(n) runfac=1; for i=1:n runfac=runfac*i; end end %MATLAB has factorial() built in

Page 7: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 8: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 9: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print

function product=myvecpro(v) product=1; for i=1:length(v) product=product*v(i); end end %MATLAB has product() built in

Page 10: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 11: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print

sum=0; for i=21:3:100 sum=sum+i; end disp(sum)

Page 12: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 13: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 14: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 15: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print

for i=1:10 for j=1:10 fprintf(‘%4d’,i*j) end fprintf(‘\n’) end

Page 16: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print

Note that initializing and incrementing are left up to you when using while.

Page 17: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 18: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 19: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 20: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 21: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 22: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 23: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 24: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 25: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 26: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 27: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print
Page 28: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print

Lab Work

Page 29: Signals & Systems Lab Lab Notes #3 - University of Kansasperrins/class/F14_360/lab/labnotes3.pdf · printstars . Matrices and nested for loops go hand-in-hand Write a script to print

Sources

Agapie, M. (2013), CS 344 Class Notes [used with permission]

Attaway, S. (2012). MATLAB a practical introduction to programming and problem solving (2nd ed.). Waltham, MA: Butterworth-Heinemann.