Matlab.

Slides:



Advertisements
Similar presentations
Introduction to Applications & Basic Features. What is MATLAB®? MATLAB® /Simulink® is a powerful software tool for: Performing mathematical computations.
Advertisements

Introduction to Programming using Matlab Session 2 P DuffourJan 2008.
P1PMF Split1 QBASIC. P1PMF Split2QBasic Command Prompt Will launch the emulator DOS operating system? Press Alt + Enter to display the widescreen.
Functions in MatLab Create a new folder on your Z:drive called MatLab_Class24 Start MatLab and change your current directory to MatLab_Class24 Topics:
EGR 106 – Week 2 – Arrays & Scripts Brief review of last week Arrays: – Concept – Construction – Addressing Scripts and the editor Audio arrays Textbook.
Division Example 2x - 3y + 4z = 10 x + 6y - 3z = 4 -5x + y + 2z = 3 A*X = B where A = B = >> X = A\B X =
Guide To UNIX Using Linux Third Edition
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
1 Creating Icons for Commands When there is not an icon related to a command in your toolbars, you will see a question mark (?). No preview available …
Introduction to MATLAB ENGR 1187 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
Digital Image Processing Lecture3: Introduction to MATLAB.
Programming For Nuclear Engineers Lecture 12 MATLAB (3) 1.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
January 24, 2005 Lecture 3 - By P. Lin 1 CPET 190 Lecture 3 Problem Solving with MATLAB
Lecture 1: Introduction Lecture series based on the text: Essential MATLAB for Engineers and Scientists By Hahn & Valentine
M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files called M- files. M-files are.
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
MATLAB File Management. MATLAB User File Management Matlab provides a group of commands to manage user files. For more information, type help iofun. pwd.
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
Shell Scripting Introduction. Agenda What is Shell Scripting? Why use Shell Scripting? Writing and Running a Shell Script Basic Commands -ECHO - REM.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
ENG 1181 College of Engineering Engineering Education Innovation Center MATLAB is a powerful program for numerical computations, plotting and programming.
Introduction to MATLAB ENGR 1181 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
Chapter 1: Getting Started with MATLAB MATLAB for Scientist and Engineers Using Symbolic Toolbox.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
CMPS 1371 Introduction to Computing for Engineers MatLab.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
Computing Fundamentals Module Lesson 10 — File Management with Windows Explorer Computer Literacy BASICS.
Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )
Introduction to MATLAB ENGR 1181 MATLAB 1. Opening MATLAB  Students, please open MATLAB now.  CLICK on the shortcut icon → Alternatively, select… start/All.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
ENG College of Engineering Engineering Education Innovation Center 1 More Script Files in MATLAB Script File I/O : Chapter 4 1.Global Variables.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
A simple classification problem Extract attributes Pattern Pattern recognition decision x C1 C2.
ENG 1181 First-Year Engineering Program College of Engineering Engineering Education Innovation Center First-Year Engineering Program MAT - Introduction.
Introduction to Eclipse Programming with an Integrated Development Environment.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Tutorial 2 : Matlab - Getting Started.
WORKSHOP 1 CO-SIMULATION.
Getting Started with Application Software
User-Written Functions
EEE 161 Applied Electromagnetics
Release Numbers MATLAB is updated regularly
BAHASA PEMROGRAMAN MATLAB as an Engineering Tool & Programming Language a lecture note for Civil Engineering students of PETRA Christian University Doddy.
SQL and SQL*Plus Interaction
Computer Literacy BASICS
Microsoft Excel A Spreadsheet Program.
Basic operations in Matlab
MATLAB DENC 2533 ECADD LAB 9.
Objectives Learn about Function procedures (functions), Sub procedures (subroutines), and modules Review and modify an existing subroutine in an event.
Variables and Arithmetic Operations
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Instructor: Raul Cruz-Cano
Lecture 1: Introduction
Advanced Data Import & Export Jeff Henrikson
Use of Mathematics using Technology (Maltlab)
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
Digital Image Processing
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Experiment No. (1) - an introduction to MATLAB
MATLAB Introduction MATLAB can be thought of as a powerful graphing calculator but with a lot more buttons! It is also a programming language, commands.
Unit 3: Variables in Java
Grauer and Barber Series Microsoft Access Chapter Two
Running a Java Program using Blue Jay.
MATLAB (Lecture 2) BY:MAHA ALMOUSA.
Tutorial 11 Using and Writing Visual Basic for Applications Code
MatLab Program Used to Calculate Interactive
Chapter 2 MATLAB Environment
Presentation transcript:

Matlab

this is the default layout for the Matlab desktop the default layout contains: menu bar tool bar current directory workspace (this is a clickable tab) command history command window

the various windows may be detached and rearranged using the controls at the upper right corners to return to the original desktop configuration, select the Desktop/Desktop Layout/Default menu option

Commands or instructions may be typed directly into the Command Window Variable a has been set to be equal to 3. It is said that the value 3 has been assigned to the variable a. By default, the result of each command is “echoed” back to the Command Window. The 3rd and 4th lines indicate that the variable a exists and that its current value is 3. That value will remain until another command changes it. The variables and their current values may also be observed in the Workspace window (click on the tab)

The blank lines in the output on the Command Window can be eliminated by entering the “Format Compact“ command Assign the value of 6 to a new variable b and note that the output is shown without blank lines Set the variable c to the sum of a and b The “echoed” output resulting from executing a command can be eliminated by adding a semicolon to the end of the command To force the value of a variable to be displayed, simply type the variable name on a command line If a calculated result is not assigned to a variable then, by default, it is assigned to a variable ans which is short for answer The command to clear the command window is “clc”

Note the listing of the variables in the Workspace Window These variables will exist until the workspace is emptied with the “clear” command

We are going to calculate the volume of a cylindrical tank using Set the values of the variables d (diameter) and h (height) to 3 and 5, respectively. The value of pi is built into Matlab as fixed constant Set the variable Area to the tank cross-sectional area Set the variable Volume equal to the calculated tank volume The calculated volume can be displayed with much greater resolution by entering the “format long” command

The Command Window is useful, but its not really programming The Command Window is useful, but its not really programming. We want tor record our commands in a file as a series of program instruction and then execute them by accessing the file. The first step is to set the storage location for our program files, i.e., the “Current Directory.” By default, Matlab, starts with the current directory set to a work area on drive: C of the computer at which you are sitting. You will have to come back to the same computer to continue working on your programs which is not acceptable. Click on the “Browse” button. Select a folder on your TechDrive or on a USB Drive to be your current directory Its good practice to put all of your work in a single Matlab folder with separate folders for each project. Create a folder Matlab/Project 1.

Note the new current directory Start the text editor by selecting the File/New/M-File menu option Enter the program lines in the Editor window for the volume calculation. Be careful to replicate the use of uppercase and lowercase for the variable names as shown. Select File/Save As and save the file as cylindrical_tank.m All Matlab files use a .m filename extension and are referred to as M-files. Note the use of an underline rather than a space in the filename. The simplifies references to the file on the command line.

Click on the Current Directory tab and note the presence of your file. Right-click on the file name in the Current Directory window and select Run from the popup menu Note the output in the Command Window Display of the value assigned to H is a result of not ending that line with a semicolon. The output was suppressed on the other lines by ending them with the semicolon. The disp( ) function is used to force the display of program output on the Command Window. The first disp() causes the display of the characters enclosed in quotes. The second disp() causes the display of the value of the variable volume.

Click on the Workspace tab to display the Workspace Window. Note that in addition to the variables that were used in the program (D, H, area, and volume), the previously defined variables (d, h, Area, and Volume) are still there. This is a very easy to commit potential error. If we had accidently used the variable d instead of D in the program, the diameter would have been taken as 3 instead of 4. It is good practice to begin each program with a “clear” command in the M-file so that each program execution starts with a clean workspace.

The program would be more useful if the user could change the values used for the diameter and height. Modify the program to include the two input() commands as shown. The input() function displays the prompt that in the parameter list, i.e., between the open and close parentheses. Type cylindrical_tank on the command line. Matlab will look in your current directory for an M-file with that name and if it finds one, it will try to execute it. Respond to the program prompts.

The height of a rock thrown upwards can be calculated from Create a program rock.m that takes the initial velocity and time as inputs and generates the height as output as shown above.

The power input requirement for a pump can be calculated from Create a program pump.m that takes the flow rate, pressure jump, and efficiency as inputs and generates the power requirement as output as shown above.

The stretch or change in length of an axially loaded rod can be calculated from Create a program stretch.m that takes the load, diameter, length, and modulus of elasticity as inputs and generates the length change as output as shown above.