40
Signals & Systems Signals & Systems Introduction to MATLAB Introduction to MATLAB Bo Bo- -Yuan Peng Yuan Peng E.E. Dept., E.E. Dept., National Taiwan University National Taiwan University

MATLAB2010

  • Upload
    ghalzai

  • View
    217

  • Download
    0

Embed Size (px)

Citation preview

Page 1: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 1/40

Signals & SystemsSignals & Systems

Introduction to MATLABIntroduction to MATLAB

BoBo--Yuan PengYuan Peng

E.E. Dept.,E.E. Dept.,National Taiwan UniversityNational Taiwan University

Page 2: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 2/40

Before the talk starts«Before the talk starts«

Our course website:Our course website:

http://cktlab.ee.ntu.edu.tw/ss2010springhttp://cktlab.ee.ntu.edu.tw/ss2010spring

Remember to be concerned about anyRemember to be concerned about anyof the changes on our course website.of the changes on our course website.

Page 3: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 3/40

The Course Web SiteThe Course Web Site

Page 4: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 4/40

OutlineOutline

What is MATLAB?What is MATLAB?

Where to use MATLAB?Where to use MATLAB?

How to use MATLAB?How to use MATLAB? Homework 1Homework 1

Page 5: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 5/40

What is MATLAB?What is MATLAB?

MATLAB is an interactive environment inMATLAB is an interactive environment inwhich you can write programs to do manywhich you can write programs to do manypowerful calculation.powerful calculation.

Number calculationNumber calculation

Matrix calculationMatrix calculation

Plots and/or sketches of mathematical graphsPlots and/or sketches of mathematical graphs

Symbolic calculationSymbolic calculation

Differential EquationsDifferential Equations

BlablablaBlablabla««

Page 6: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 6/40

Where to use MATLAB?Where to use MATLAB?

The MathWorks, Inc. sells MATLAB.The MathWorks, Inc. sells MATLAB. If you are rich, then you may use it at home.If you are rich, then you may use it at home.

If you are poorIf you are poor««??

Fortunately, this university is rich.Fortunately, this university is rich. You can use MATLAB at Computer Center.You can use MATLAB at Computer Center.

MATLAB is installed in every computer in everyMATLAB is installed in every computer in everycomputer classroom in CC Building.computer classroom in CC Building.

MATLAB is installed in every computer in EEII107.MATLAB is installed in every computer in EEII107.

Also, you can connect to the SoftAlso, you can connect to the Soft--Bank provided byBank provided byComputer Center to access MATLAB remotely, givenComputer Center to access MATLAB remotely, givenyour IP is 140.112.x.x .your IP is 140.112.x.x .

http://softbank.cc.ntu.edu.tw/http://softbank.cc.ntu.edu.tw/

Only 6 licenses available. DONOnly 6 licenses available. DON¶¶T OCCUPY the resource.T OCCUPY the resource.

Page 7: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 7/40

SoftSoft--Bank in CCBank in CC

Page 8: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 8/40

SoftSoft--Bank in CCBank in CC

Page 9: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 9/40

SoftSoft--Bank in CCBank in CC

Page 10: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 10/40

SoftSoft--Bank in CCBank in CC

Page 11: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 11/40

How to Access MATLAB at Home?How to Access MATLAB at Home?

SoftSoft--Bank can be accessed only if Bank can be accessed only if your IP is 140.112.x.x .your IP is 140.112.x.x .

Solution: Virtual Private NetworkSolution: Virtual Private Network https://sslvpn.ntu.edu.tw/https://sslvpn.ntu.edu.tw/

You can logYou can log--in with your studentin with your studentaccount provided by CC.account provided by CC.

Page 12: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 12/40

 Access MATLAB at Home Access MATLAB at Home

Page 13: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 13/40

 Access MATLAB at Home Access MATLAB at Home

Page 14: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 14/40

 Access MATLAB at Home Access MATLAB at Home

Page 15: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 15/40

Page 16: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 16/40

How to use MATLAB?How to use MATLAB?

You will have to know the pathYou will have to know the pathwhere MATLAB is installed. In CC, itwhere MATLAB is installed. In CC, itis installed in C:is installed in C:\ \ProgramProgramFilesFiles\ \MATLAB .MATLAB .

All of your programs in MATLAB shouldAll of your programs in MATLAB shouldbe put into C:be put into C:\ \ProgramProgram

FilesFiles\ \MATLABMATLAB\ \work in order to use thework in order to use thefile.file.

Page 17: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 17/40

Page 18: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 18/40

How to use MATLAB?How to use MATLAB?

First testFirst test

Simple calculationSimple calculation ++, , --, , **, , //, , ^̂, , mod()mod()

OperatorsOperators

UseUse helphelp

VariablesVariables

No need to declare. Just use it.No need to declare. Just use it.

DO NOT use variable i and j. They areDO NOT use variable i and j. They areimaginary numbers.imaginary numbers.

MatricesMatrices

Use of squared bracketUse of squared bracket [ ][ ]

** vs.vs. .*.*;; // vs.vs. ././

Page 19: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 19/40

Page 20: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 20/40

Page 21: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 21/40

Page 22: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 22/40

Page 23: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 23/40

Page 24: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 24/40

Page 25: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 25/40

How to use MATLAB?How to use MATLAB?

The use of operatorThe use of operator ::

plot()plot(),, stem()stem(),, subplot()subplot()

Flow ControlFlow Control if if «« elseif elseif «« elseelse«« endend

switchswitch«« casecase«« otherwiseotherwise«« endend

for, while, continue, breakfor, while, continue, break

Page 26: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 26/40

Page 27: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 27/40

Page 28: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 28/40

Page 29: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 29/40

Page 30: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 30/40

Page 31: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 31/40

Page 32: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 32/40

Page 33: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 33/40

How to use MATLAB?How to use MATLAB?

mm--file: a batch of MATLAB commandfile: a batch of MATLAB command

You can edit an mYou can edit an m--file and save it in thefile and save it in thework folderwork folder

Use it as a commandUse it as a command

Page 34: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 34/40

Page 35: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 35/40

Page 36: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 36/40

Page 37: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 37/40

Page 38: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 38/40

How to use MATLAB?How to use MATLAB?

If you want to plot a lot of graphsIf you want to plot a lot of graphs««

subplot()subplot()

figure()figure()

pausepause

Page 39: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 39/40

Page 40: MATLAB2010

8/7/2019 MATLAB2010

http://slidepdf.com/reader/full/matlab2010 40/40

Homework 1Homework 1

Download the .pdf file and the .zip fileDownload the .pdf file and the .zip filewith mwith m--files inside.files inside.

Pick mPick m--files from the .zip file.files from the .zip file. F

ollow the instructions inside the .pdf fileFollow the instructions inside the .pdf fileto construct one proper mto construct one proper m--file.file.

Do discussion with the results in a .pdf file.Do discussion with the results in a .pdf file. You may do discussion in Word 2007 then saveYou may do discussion in Word 2007 then save

it as a .pdf file.it as a .pdf file.

Compress the discussion and the mCompress the discussion and the m--filefileinto one .zip/.rar file.into one .zip/.rar file.

Upload the compressed file to the website.Upload the compressed file to the website.