CSCI N317 Computation for Scientific Applications Unit 1 – 1 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 C Programming
Division Example 2x - 3y + 4z = 10 x + 6y - 3z = 4 -5x + y + 2z = 3 A*X = B where A = B = >> X = A\B X =
CIS101 Introduction to Computing Week 09 Spring 2004.
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.
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.
Introduction to programming in MATLAB MATLAB can be thought of as an super-powerful graphing calculator Remember the TI-83 from calculus? With many more.
Digital Image Processing Lecture3: Introduction to MATLAB.
Lecture 1: Introduction Lecture series based on the text: Essential MATLAB for Engineers and Scientists By Hahn & Valentine
BRIAN D. HAHN AND DANIEL T. VALENTINE THIRD EDITION Essential MATLAB® for Engineers and Scientists.
Introduction to Python
CSC141 Introduction to Computer Programming
Lecture 4 MATLAB Windows Arithmetic Operators Maintenance Functions
Introduction to MATLAB. Windows in MATLAB Command Window – where you enter data, run MATLAB code, and display results Command History - displays a log.
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.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
1 Functions 1 Parameter, 1 Return-Value 1. The problem 2. Recall the layout 3. Create the definition 4. "Flow" of data 5. Testing 6. Projects 1 and 2.
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.
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
CMPS 1371 Introduction to Computing for Engineers MatLab.
Introduction to Programming with RAPTOR
Advanced Topics- Functions Introduction to MATLAB 7 Engineering 161.
MATLAB Technical Computing Environment. MATLAB Matlab is an interactive computing environment that enables numerical computation and data visualization.
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 &
Getting Started with MATLAB (part2) 1. Basic Data manipulation 2. Basic Data Understanding 1. The Binary System 2. The ASCII Table 3. Creating Good Variables.
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
EGR 115 Introduction to Computing for Engineers Introduction to MATLAB Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
ENG 1181 First-Year Engineering Program College of Engineering Engineering Education Innovation Center First-Year Engineering Program MAT - Introduction.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
The Hashemite University Computer Engineering Department
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
Matlab for Engineers Matlab Environment Chapter 2.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
Introduction to Programming
3 A Guide to MySQL.
Matlab Programming for Engineers
Introduction to MATLAB
Release Numbers MATLAB is updated regularly
Introduction to Matlab
Key Ideas from day 1 slides
Matlab Training Session 4: Control, Flow and Functions
Lecture: MATLAB Chapter 1 Introduction
MATLAB Basics Nafees Ahmed Asstt. Professor, EE Deptt DIT, DehraDun.
Variables, Expressions, and IO
Basic operations in Matlab
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Lecture 1: Introduction
Use of Mathematics using Technology (Maltlab)
Digital Image Processing
Topics Designing a Program Input, Processing, and Output
funCTIONs and Data Import/Export
CSE 307 Basics of Image Processing
Using SQL*Plus.
Experiment No. (1) - an introduction to MATLAB
Using Script Files and Managing Data
Chapter 1: Programming Basics, Python History and Program Components
Executive Reports, Instructions and Documentation
Presentation transcript:

CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB Introduction

Overview MATLAB – Matrix Laboratory (designed to make matrix computations particularly easy) A powerful technical computing system for handling scientific and engineering calculations Essential requirements for successful MATLAB applications Must learn the exact rules for writing MATLAB statements and using MATLAB utilities Must know the mathematics associated with the problem you want to solve Must develop a logical plan of attack – the algorithm for solving a problem

Using MATLAB MATLAB must be installed on a computer MATLAB is available on IUAnyWare Windows operating system is used in this class, but MATLAB is available for Unix or MAC Exit MATLAB click the X (close box) or Type quit or exit at the command window prompt and hit Enter

Working Folder Starting MATLAB will automatically create a folder named MATLAB in the user’s Documents folder. This is the default working folder. Anything saved from the Command Window will be saved here. Can change the default working folder.

Command Window The line with the >> prompt is called the command line. Type in a command at the command line and hit Enter to execute the command. Use Up-arrow and Down-arrow to select a command you have entered. Smart recall feature – type the first few characters of the command you want to recall then press the Up-arrow key. clear and command window: type clc or Right click on your mouse -> Clear Command Window Can save your commands in a script file

Variables A variable is the representation of a memory address unit on a computer where a certain value can be stored E.g. a = 2 means to store the value to the memory address labeled as a. Read as “a gets 2” What is the value of b after the following of commands are executed? a=2; b = 3; a=3+b; b = a + 10;

Variables The semicolon ; prevents the result to be displayed in the command window. You can view the values of variables in the workspace window. ans is used to store the most recent result if it is not stored in a user defined variable. . To destroy a variable, use the command clear clear a; %destroy variable a clear all %destroy all variables Once a variable is destroyed, it doesn’t exist any more thus cannot be used in commands.

Built-in Functions and Commands MATLAB has a lot of built-in functions (see Appendix B of the textbook or MATLAB documentation) E.g. a = 4; sqrt(a); E.g. date(); A function returns a value. A command does something, e.g. clear a destroy the variable a. clc clears the command window.

More Tab completion – type in the first few letters of a command and press the Tab key. % is a flag that indicates characters to the right of this symbols are comments. You can use Shift+Enter to enter multiple lines and run them together You can copy codes from the command history window in the command line whos command will list the variables currently in the workspace If you copy commands from the slides or WORD document into the command window, you might need to retype single quotes or other special characters. Type in demo to get more help

Running a Script A script is a file that contains some commands (also called scripts or statements) to be executed. Click on New Script or type edit at the command line, and type in some commands in the Editor window, then click “Run” . You will be asked to save the script file. The result will show in the command window. All the script files has the .m extension, called M-files, e.g. a1.m Type in the file name a1 at the command window or select the file in the Current Folder window and right click “Run” will run the commands in the script file.

Writing a Program Problem: Find the new balance You deposited $1000 into a bank. The interest rate is 3% per year. What will the balance be after one year?

Writing a Program Algorithm design Use English or half English half code (pseudo-code) to describe in details how to solve a problem (a structure plan) English: create a variable called balance whose value is 1000. pseudo-code: create variable balance = 1000; The essence of any structured plan can be summarized as Input: Declare and assign input variables Operations: What to do with the input variables to solve the problem? Output: Display results

Writing a Program Algorithm design Input Prepare data, create variables to store balance and interest rate, balance = 1000; rate = 0.03 Operations Calculate and store interest, interest = balance * rate Add interest to balance and store result, newBalance = balance + interest Output Display new balance Coding Process: translate the algorithm into MATLAB language … The function for displaying a result is disp() disp(‘New Balance:’); disp(balance);