{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
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
Image of page 2
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
Image of page 3

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

View Full Document Right Arrow Icon
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
Image of page 4
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')
Image of page 5

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

View Full Document Right Arrow Icon
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
Image of page 6
Matlab Data Files (not in the text) Types: .asv = auto save ascii = regular text files .mat = Matlab’s proprietary format (multiple variables)
Image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern