Upload
ghalzai
View
217
Download
0
Embed Size (px)
Citation preview
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
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.
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 3/40
The Course Web SiteThe Course Web Site
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
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««
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.
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 7/40
SoftSoft--Bank in CCBank in CC
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 8/40
SoftSoft--Bank in CCBank in CC
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 9/40
SoftSoft--Bank in CCBank in CC
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 10/40
SoftSoft--Bank in CCBank in CC
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.
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 12/40
Access MATLAB at Home Access MATLAB at Home
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 13/40
Access MATLAB at Home Access MATLAB at Home
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 14/40
Access MATLAB at Home Access MATLAB at Home
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 15/40
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.
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 17/40
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. ././
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 19/40
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 20/40
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 21/40
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 22/40
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 23/40
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 24/40
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
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 26/40
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 27/40
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 28/40
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 29/40
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 30/40
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 31/40
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 32/40
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
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 34/40
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 35/40
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 36/40
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 37/40
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
8/7/2019 MATLAB2010
http://slidepdf.com/reader/full/matlab2010 39/40
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.