mat lab 2009

Upload: lello-flo

Post on 05-Apr-2018

232 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 Mat Lab 2009

    1/40

    Signals & Systems

    Introduction to MATLABBo-Yuan Peng

    E.E. Dept.,National Taiwan University

  • 8/2/2019 Mat Lab 2009

    2/40

    Before the talk starts

    Our course website:

    http://cktlab.ee.ntu.edu.tw/ss2009spring

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

    http://cktlab.ee.ntu.edu.tw/ss2009springhttp://cktlab.ee.ntu.edu.tw/ss2009spring
  • 8/2/2019 Mat Lab 2009

    3/40

    The Course Web Site

  • 8/2/2019 Mat Lab 2009

    4/40

    Outline

    What is MATLAB?

    Where to use MATLAB?

    How to use MATLAB? Homework 1

  • 8/2/2019 Mat Lab 2009

    5/40

    What is MATLAB?

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

    Number calculation Matrix calculation

    Plots and/or sketches of mathematical graphs

    Symbolic calculation

    Differential Equations

    Blablabla

  • 8/2/2019 Mat Lab 2009

    6/40

    Where to use MATLAB?

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

    If you are poor?

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

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

    MATLAB is installed in every computer in EEII107.

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

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

    Only 6 licenses available. DONT OCCUPY the resource.

    http://softbank.cc.ntu.edu.tw/http://softbank.cc.ntu.edu.tw/
  • 8/2/2019 Mat Lab 2009

    7/40

    Soft-Bank in CC

  • 8/2/2019 Mat Lab 2009

    8/40

    Soft-Bank in CC

  • 8/2/2019 Mat Lab 2009

    9/40

    Soft-Bank in CC

  • 8/2/2019 Mat Lab 2009

    10/40

    Soft-Bank in CC

  • 8/2/2019 Mat Lab 2009

    11/40

    How to Access MATLAB at Home?

    Soft-Bank can be accessed only ifyour IP is 140.112.x.x .

    Solution: Virtual Private Network

    https://sslvpn.ntu.edu.tw/

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

    https://sslvpn.ntu.edu.tw/https://sslvpn.ntu.edu.tw/
  • 8/2/2019 Mat Lab 2009

    12/40

    Access MATLAB at Home

  • 8/2/2019 Mat Lab 2009

    13/40

    Access MATLAB at Home

  • 8/2/2019 Mat Lab 2009

    14/40

    Access MATLAB at Home

  • 8/2/2019 Mat Lab 2009

    15/40

    How to use MATLAB?

    If you are using MATLAB from Soft-Bank, just click it on.

    If you are using MATLAB in thecomputer classroom in CC, selectStart -> Programs -> MATLAB ->MATLAB will turn on MATLAB.

  • 8/2/2019 Mat Lab 2009

    16/40

    How to use MATLAB?

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

    Files\MATLAB . All of your programs in MATLAB should

    be put into C:\Program

    Files\MATLAB\work in order to use thefile.

  • 8/2/2019 Mat Lab 2009

    17/40

  • 8/2/2019 Mat Lab 2009

    18/40

    How to use MATLAB?

    First test

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

    Operators

    Use help Variables

    No need to declare. Just use it.

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

    Matrices

    Use of squared bracket [ ]

    * vs. .*; / vs. ./

  • 8/2/2019 Mat Lab 2009

    19/40

  • 8/2/2019 Mat Lab 2009

    20/40

  • 8/2/2019 Mat Lab 2009

    21/40

  • 8/2/2019 Mat Lab 2009

    22/40

  • 8/2/2019 Mat Lab 2009

    23/40

  • 8/2/2019 Mat Lab 2009

    24/40

  • 8/2/2019 Mat Lab 2009

    25/40

    How to use MATLAB?

    The use of operator :

    plot(), stem(), subplot()

    Flow Control if elseif else end

    switch case otherwise end

    for, while, continue, break

  • 8/2/2019 Mat Lab 2009

    26/40

  • 8/2/2019 Mat Lab 2009

    27/40

  • 8/2/2019 Mat Lab 2009

    28/40

  • 8/2/2019 Mat Lab 2009

    29/40

  • 8/2/2019 Mat Lab 2009

    30/40

  • 8/2/2019 Mat Lab 2009

    31/40

  • 8/2/2019 Mat Lab 2009

    32/40

  • 8/2/2019 Mat Lab 2009

    33/40

    How to use MATLAB?

    m-file: a batch of MATLAB command

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

    Use it as a command

  • 8/2/2019 Mat Lab 2009

    34/40

  • 8/2/2019 Mat Lab 2009

    35/40

  • 8/2/2019 Mat Lab 2009

    36/40

  • 8/2/2019 Mat Lab 2009

    37/40

  • 8/2/2019 Mat Lab 2009

    38/40

    How to use MATLAB?

    If you want to plot a lot of graphs

    subplot()

    figure()

    pause

  • 8/2/2019 Mat Lab 2009

    39/40

    How to use MATLAB?

    Functions in MATLAB

    Youd better to use one m-file with one

    function.

    syntax: function y = foo()

    Some useful function

    zeros()

    ones()

  • 8/2/2019 Mat Lab 2009

    40/40

    Homework 1

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

    Pick m-files from the .zip file. Follow the instructions inside the .pdf file

    to construct one proper m-file. Do discussion with the results in a .pdf file.

    You may do discussion in Word 2007 then saveit as a .pdf file.

    Compress the discussion and the m-fileinto one .zip/.rar file. Upload the compressed file to the website.