Introduction. Chapter 1



Similar documents
Computer Basics: Tackling the mouse, keyboard, and using Windows

Tutorial Guide to the IS Unix Service

Mesa DMS. Once you access the Mesa Document Management link, you will see the following Mesa DMS - Microsoft Internet Explorer" window:

Maple Quick Start. Introduction. Talking to Maple. Using [ENTER] 3 (2.1)

FIRST STEPS WITH SCILAB

Introduction to Matlab

Windows Basics. Developed by: D. Cook

AMATH 352 Lecture 3 MATLAB Tutorial Starting MATLAB Entering Variables

Introduction to MS WINDOWS XP

Beginner s Matlab Tutorial

Windows 8.1 Tips and Tricks

1. Right click using your mouse on the desktop and select New Shortcut.

Microsoft PowerPoint 2010 Handout

How To Unlink Your Computer From Dropbox From Your Computer To Your Computer (For A Free Download) From Your Dropbox Account (For Free) (For An Ubuntu Install) (Free Download) (Unlock) (Reboot)

Introduction to the use of the environment of Microsoft Visual Studio 2008

Creating Custom Crystal Reports Tutorial

Creating a Website with Publisher 2013

Content Author's Reference and Cookbook

Introduction to Computers: Session 3 Files, Folders and Windows

Module One: Getting Started Opening Outlook Setting Up Outlook for the First Time Understanding the Interface...

Your Buckalew RWD Website (April 2008; updated Feb. 2010)

For Introduction to Java Programming, 5E By Y. Daniel Liang

SMART Board Menu. Full Reference Guide

Adobe Dreamweaver CC 14 Tutorial

Tutorial: Get Running with Amos Graphics

NetMeeting - User Guide

Introduction to SPSS 16.0

Module 1. 4 Login-Send Message to Teacher

Excel Companion. (Profit Embedded PHD) User's Guide

Getting Started with Excel Table of Contents

WebEx Sharing Resources

I ntroduction. Accessing Microsoft PowerPoint. Anatomy of a PowerPoint Window

Introduction to R Statistical Software

Chapter 23 File Management (FM)

Introduction to R Statistical Software

Fairfield University Using Xythos for File Sharing

The Helios Microsoft Windows Server

Introduction to Windows XP Operating System

Lab 2: MS ACCESS Tables

COMPUTER BASICS. Gordon Kelley Academic Success Center Vines Building, Room

Tutorial: Get Running with Amos Graphics

Creating a Guest Book Using WebObjects Builder

Lab 3: Introduction to Data Acquisition Cards

WebEx Remote Access User s Guide

Create a New Database in Access 2010

Module 1: Getting Started With Altium Designer

In-Class Lab Assignment

Create a Poster Using Publisher

Desktop, Web and Mobile Testing Tutorials

Appendix: Tutorial Introduction to MATLAB

Password Protection Application for Verbatim USB Flash Drives

Lab 0: Preparing your laptop for the course OS X


Appendix A How to create a data-sharing lab

Computer Programming In QBasic

How To Use Spss

Using SSH Secure Shell Client for FTP

Creating a Web Site with Publisher 2010

4 Other useful features on the course web page. 5 Accessing SAS

MATLAB Functions. function [Out_1,Out_2,,Out_N] = function_name(in_1,in_2,,in_m)

2 SQL in iseries Navigator

Using SSH Secure File Transfer to Upload Files to Banner

WINDOWS 7 MANAGE FILES AND FOLDER WITH WINDOWS EXPLORER

Chapter 4: Website Basics

Microsoft PowerPoint 2008

Virtual Office Remote Installation Guide

Remote Desktop Services

Remote Desktop Connection (Windows XP) -A tutorial for UH College of Education faculty and staff - Setting up Remote Access on my Work Computer

Appendix K Introduction to Microsoft Visual C++ 6.0

Creating Personal Web Sites Using SharePoint Designer 2007

Browsing and working with your files and folder is easy with Windows 7 s new look Windows Explorer.

MICROSOFT OFFICE LIVE MEETING GUIDE TO RECORDING MEETINGS

Composing a New Message

File Management With Windows Explorer

Content Author's Reference and Cookbook

Code::Blocks Student Manual

GETTING STARTED TABLE OF CONTENTS

StrikeRisk v6.0 IEC/EN Risk Management Software Getting Started

Book Builder Training Materials Using Book Builder September 2014

A Crash Course in OS X D. Riley and M. Allen

Overview... 2 How to Add New Documents... 3 Adding a Note / SMS or Phone Message... 3 Adding a New Letter How to Create Letter Templates...

SoftChalk. Level 1. University Information Technology Services. Training, SoftChalk Level Outreach, 1 Learning Technologies and Video Production

SMART Board Training Outline Trainer: Basel Badran

Mapping ITS s File Server Folder to Mosaic Windows to Publish a Website

Now part of ALLSCRIPTS. HealthMatics EMR Input Manager

BIGPOND ONLINE STORAGE USER GUIDE Issue August 2005

About the HealthStream Learning Center

HOW TO USE THE File Transfer Protocol SERVER ftp.architekturaibiznes.com.pl

This Skill Builder demonstrates how to define and place sketched symbols in drawings.

Microsoft PowerPoint 2010

Search help. More on Office.com: images templates

Crystal Reports Payroll Exercise

voxover 1.x Manual by Matthew Foust and Evan Olcott Copyright 2007 Audiofile Engineering, LLC

Introduction to Simulink

Export. Exporting Client Addresses

Basic File Management & Navigation

Advanced Presentation Features and Animation

KI6501 Data Manager. Software User Manual

Windows XP Pro: Basics 1

PowerPoint 2013: Basic Skills

Transcription:

Chapter 1 Introduction MATLAB (Matrix laboratory) is an interactive software system for numerical computations and graphics. As the name suggests, MATLAB is especially designed for matrix computations: manipulating arraays, solving systems of linear equations, computing eigenvalues and eigenvectors, factoring matrices, and so forth. In addition, it has a variety of graphical capabilities: plotting data, creating animations, creating user interfaces, and can be extended through programs written in its own programming language. MATLAB is designed to solve problems numerically, that is, in finite-precision arithmetic. Therefore it produces approximate rather than exact solutions, and should not be confused with a symbolic computation system (SCS) such as Mathematica or Maple. It should be understood that this does not make MATLAB better or worse than an SCS; it is a tool designed for different tasks and is therefore not directly comparable. In the following sections, we give an introduction to some of the most useful features of MAT- LAB. We include plenty of examples; the best way to learn to use MATLAB is to read this while running MATLAB, trying the examples and experimenting. 1.1 Starting MATLAB Microsoft Windows: Double -click on the MATLAB shortcut icon on the Windows desktop, or find it under Start - Programs - Math & Numerical Metehods - Matlab 6.5 - Matlab 6.5 Linux: Type MATLAB at the operating system prompt. 1.2 Quitting MATLAB To end your MATLAB session, select Exit MATLAB from the File menu in the desktop, or type quit in the Command Window. To execute specified functions each time MATLAB quits, such as saving the workspace, you can create and run a finish.m script. 1.3 MATLAB Environment When you start MATLAB, a special window called the MATLAB desktop appears, Figure 1.1. It integrates many tools for managing files, variables, applications, and debugging within the MAT- LAB environment. This is what is known as an integrated development environment (IDE). 1

1.4 The Desktop The major tools within or accessible from the desktop are: Window Command Window Command History Launch Pad Help Browser Current Directory Workspace Editor/Debugger Figure Window Array Editor Purpose Main window: for running functions and entering variables Logs previously run commands in the Command Window Provides access to tools, demos, and documentation Provides help for accessing documentation Browser for accessing files Provides information about the variables that are used Helpful in creating, modifying, and debugging MATLAB script and function files (M-files) Contains output from graphic commands Browser for editing arrays 1.4.1 Command Window Use the command window to enter variables and run functions and M-files. Type the functions and variables at the MATLAB prompt (>>) and they will be executed on the spot 2

. Use tab to go to Current Directory browser Get Help Enter MATLAB Functions View or change current directory Click to move window outside of desktop close window Expand to view documentation, demos, and tools View or use previously run functions Drag the separator bar to resize windows Figure 1.1 1.4.2 Notes on working with the Command Window To type a command, the cursor MUST be placed next to the command prompt >> The end of a command is when the Enter key is pressed. Once a command is entered, it is executed. However, only the last command is executed. Previous commands are unaltered and unexecuted. Several command may be typed on the same line by typing a comma, between the commands. Again, when the Enter key is pressed, the commands are executed in order from left to right. A previous command may be recalled to be the current command by using the up arrow. When the command is displayed at the command prompt, it can be modified is needed and then executed. The down-arrow may be used to move down the previously typed commands. 3

If a command is too long to fit on one line, it can be split between lines by typing three periods..., pressing the Enter key, and continuing the command on the next line. A command may extended over several lines up to a total of 4096 characters. 1.4.3 Continuation and Suppress Echo: MATLAB Statement: Terminated by an end-of-line <carriage return> unless you put a... at the end of the line to continue. Can also terminate with a semicolon ; which suppresses the echo of the statement. x1 = 1 + 1/2 + 1/3 + 1/4... + 1/5 + 1/6; Continuation:... Suppress echo: ; >> x = 3 %evaluation printed x = C++ Statement: Terminated with a semicolon x1 = 1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6; NA NA 3 >> x = 3; %evaluation suppressed >> 1.4.4 Comments: MATLAB % a single line comment v = 1584; %Initial velocity (km/h) C++ // single line comment /* a multi-line comment */ 1.4.5 The clc command: The clc command clears the Command Window. After a period of time working in the Command Window, the display may become long. The clc command puts it back to a blank window. 1.4.6 Running External Programs You can run external programs from the MATLAB Command Window, i.e., an editor of your choice. The exclamation point character! is a shell escape and indicates that the rest of the 4

input line is a command to the operating system. This is useful for running other program without quitting MATLAB. Example:!emacs proj7.m will invoke the emacs editor for the file called proj7.m. When you exit the external program, the operating system returns control to MATLAB. 1.4.7 Command History Window The commands you enter in the Command Window are logged in the Command History window. In Command History, you can view previously used functions, and copy and paste to the Command Windows to execute your selected lines. You can erase your command history by selecting Clear Command History from the Edit menu. Timestamp marks the start of each session Select one or more lines and right-click to copy, evaluate, or create an m-file from the selection 5

1.4.8 Launch Pad Window The Launch Pad gives easy access to the different tools within MATLAB. You may need to go through the Start Button (lower left-hand corner) to get to the Launch Pad. Tools - double-click to open the tool Help - double click to go directly to documentation Demos - double-click to display the demo launcher 1.4.9 Help Use the Help Browser to search for and view documentation. It is a web browser that displays HTML documents. There are many ways to get to the Help Browser click the help button? in the toolbar type helpbrowser in the Command Window pick Help from the Launch Pad choices 1.4.10 Current Directory MATLAB file operations use the current directory and the search path as reference points. Any file you want to run must either be in the current directory or on the search path. A quick way to view or to change the current directory is by using the Current Directory field on the desktop toolbar. To search for, view, open, or make changes to MATLAB M-files related directories/files, use the Current Directory browser. 1.4.11 Editor/Debugger The Editor Window is used for writing and editing programs and functions. This window is opened from the File option of the Main Menu Bar. The Editor/Debugger provides a graphical user interface for basic text editing along with M-file debugging. An example of an Editor Window is shown below. 6

You can set breakpoints where you want execution to pause so you can examine the values of the variables. Hold the cursor over a variable and its current value will appear You can display the contents of an M-file in the Command Window by using the type command. >> type input_example.m %MatLab - Example of reading input from the keyboard %check to make sure that the values are within range %loop back if they are not % all digits will be from 1-9 ones = [1 1 1 1]; nines = [9 9 9 9]; board = [ 0 0 0 0]; indices = []; while length(indices) < 4 guess = input('\nplease enter your guesses--format of [a b c d] : '); %check if guesses are within range %if not within range, get another guess done = (guess==0); 7

if length(find(done)) == 4 fprintf('\nthanks for playing. I win - you gave up ') return else inrange = (ones <= guess & guess <= nines); indices = find(inrange); if length(indices) < 4 fprintf(' You need to enter values from 1-9 '); else fprintf(' Your code goes here\n\n') end end end fprintf ('Congratulations You WIN!!!!!'); 8