Lecture5 - EGR 106 Lecture 5 Editor, Scripts, Input/Output...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: EGR 106 Lecture 5 Editor, Scripts, Input/Output Review of Script Files & Editor Input and Output Commands Error Messages & Debugging Applications Textbook 4.1-4.5 Review of Script (m-file) Concept A file containing MATLAB commands – Can be re-executed – Is easily changed/modified or e-mailed to someone Commands are executed one by one, sequentially – File is executed by typing its name (without .m) – Results appear in the command window (or use ; ) Can be created using any text editor – .m extension – Listed in Current Directory window MATLAB’s Built-in, C o l o r Editor: – Can create a new file or open an existing M file (icons or click on file name) – C o l o r used to aid in file creation (command types, typos, etc.) Opens Editor Window to Create New M-File Opens an Existing File in Editor Window to Edit & Save – typical Windows menu – line numbers – “run” button or F5 – debug capability } note use of semicolons to suppress screen output of unimportant variables comment lines begin with percent sign note automatic change of colors to help programmer Typical Example of Script File in Editor Window How scripts get data: – From arrays in the current workspace load file_name – From arrays defined in the script or Command Window – Using the “input” command: Numeric: x = input(' how many? ') String: x = input(' name? ', 's') How scripts show or output data: – Use of array name command – Use of display command: Existing array (a single array only – if necessary, use [ ] !!) disp(x) or disp([x,y]) Text disp(' The task is done ') – Use of fprintf command – Save command (creates *.mat file) save file_name Matlab Data Files (not in the text) Types: – .asv = auto save – ascii = regular text files – .mat = Matlab’s proprietary format (multiple variables)...
View Full Document

This note was uploaded on 10/03/2011 for the course EGR 106 taught by Professor Taggart during the Spring '09 term at Rhode Island.

Page1 / 19

Lecture5 - EGR 106 Lecture 5 Editor, Scripts, Input/Output...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online