CIM4305 Computer Aided Analysis - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

CIM4305 Computer Aided Analysis

Description:

Typing at the command window can become slow and inefficient ... Example1. This Week. Work through Exercise 3. Use Notes 2 to help you ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 14
Provided by: janeterr
Category:

less

Transcript and Presenter's Notes

Title: CIM4305 Computer Aided Analysis


1
CIM4305 Computer Aided Analysis
  • Week 3 - Script M-files

2
Last Week
  • Plotting 2D and 3D Graphs
  • Adding Titles and Labels
  • Setting Properties
  • Line style Colour and Markers
  • Controlling the axis
  • Multiple Plots
  • Useful commands
  • Figure Hold on Hold off Close all Figure

3
This Week
  • Script M-files
  • Commenting
  • Current Working Directory

4
Script M-files
  • Typing at the command window can become slow and
    inefficient
  • Re-evaluating a large number of commands
  • Wish to change variables
  • Script files allow any number of commands to be
    run by only typing the name of the file at the
    command window
  • gtgt example1

5
Script M-files
  • Can be saved to disk!!

6
Opening a new script file
  • File gt New gt M-file
  • Click on the blank page icon

7
Naming Files
  • Choose a name that helps you remember what the
    file does
  • The script file can be called from the command
    window using this name
  • Whilst names can contain numbers the first
    character MUST be a letter.

8
Adding Comments
  • Helps you and other people understand your code
  • Short description of what the file does
  • When was it created and who by?
  • Have there been any modifications?
  • Add comments to key parts of the code
  • GET INTO THE HABIT!!

9
Current Working Directory
  • Matlab is only able to see files in the
    directory it has been set to use
  • Important to be able to direct Matlab to where
    you work is stored
  • Default CWD is C\Matlab\work
  • Not always a good choice to save work there
  • On University machines this directory is wiped
    when you logout!

10
Seeing your CWD
  • To see which directory Matlab has as its CWD type
  • gtgt pwd
  • Print Working Directory

11
Changing you CWD
  • At the command prompt type the full address of
    the directory you wish to use
  • gtgt cd K\MatlabWork
  • OR, select the icon positioned to the right of
    the CWD window, and choose the directory you wish
    to use

12
Running a script file
  • Type the file name directly into the command
    prompt
  • gtgt Example1

13
This Week
  • Work through Exercise 3
  • Use Notes 2 to help you
Write a Comment
User Comments (0)
About PowerShow.com