Step by step set of instructions to accomplish a task or solve a problem

Similar documents
Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

Getting started with RAPTOR [Adapted from by Dr. Wayne Brown]

Introduction to Programming with RAPTOR

Mechanical Engineering Department Second Year

7 Control Structures, Logical Statements

Introduction to MATLAB Programming

Repetition Structures Chapter 9

Outline. CSE 1570 Interacting with MATLAB. Outline. Starting MATLAB. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.

Introduction to MATLAB

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

Lecture 1: Hello, MATLAB!

General Information. There are certain MATLAB features you should be aware of before you begin working with MATLAB.

Matlab Examples. (v.01, Fall 2011, prepared by HP Huang)

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.

Introduction to MATLAB Programming. Chapter 3. Linguaggio Programmazione Matlab-Simulink (2017/2018)

Introduction to Computer Programming CSCI-UA 2. Review Midterm Exam 1

Objectives. In this chapter, you will:

Finding, Starting and Using Matlab

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing

C++ Programming: From Problem Analysis to Program Design, Third Edition

Learning the Language - V

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline (Cont d) MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An

Programming 1. Script files. help cd Example:

MATLAB Introduction To Engineering for ECE Topics Covered: 1. Creating Script Files (.m files) 2. Using the Real Time Debugger

Improving and Understandability of Programming using RAPTOR

Matlab Programming Introduction 1 2

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial

Matlab Programming MET 164 1/24

VARIABLES Storing numbers:

Variable Definition and Statement Suppression You can create your own variables, and assign them values using = >> a = a = 3.

MATLAB - Lecture # 4

MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras

The same method can be used for variables that are character strings or other data types.

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain

PROGRAMMING WITH MATLAB DR. AHMET AKBULUT

Chapter 3: Programming with MATLAB

CS 302: Introduction to Programming

Introduction to MATLAB

On a 64-bit CPU. Size/Range vary by CPU model and Word size.

Starting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to.

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window.

ROSE-HULMAN INSTITUTE OF TECHNOLOGY

Variables are used to store data (numbers, letters, etc) in MATLAB. There are a few rules that must be followed when creating variables in MATLAB:

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

C: How to Program. Week /Mar/05

12 whereas if I terminate the expression with a semicolon, the printed output is suppressed.

ECE Lesson Plan - Class 1 Fall, 2001

Lecture 2 Tao Wang 1

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

Introduction to Object-Oriented Programming in MATLAB

APPM 2460 Matlab Basics

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

Selection Statements. Chapter 4. Copyright 2013 Elsevier Inc. All rights reserved 1

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1

Chapter 2 - Introduction to C Programming

Part #1. A0B17MTB Matlab. Miloslav Čapek Filip Kozák, Viktor Adler, Pavel Valtr

Outline. Data and Operations. Data Types. Integral Types

CSc Introduction to Computing

The Warhol Language Reference Manual

CISC 110 Week 3. Expressions, Statements, Programming Style, and Test Review

50 Basic Examples for Matlab

Programming Fundamentals

The Mathematics of Big Data

Fundamentals of Programming. Lecture 3: Introduction to C Programming

Why use MATLAB? Mathematcal computations. Used a lot for problem solving. Statistical Analysis (e.g., mean, min) Visualisation (1D-3D)

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Chapter 2: Basic Elements of C++

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

C++ PROGRAMMING. For Industrial And Electrical Engineering Instructor: Ruba A. Salamh

Introduction to Python

Fundamentals of Programming Session 4

MATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java

Selection Statements

Creating a C++ Program

COMP1730/COMP6730 Programming for Scientists. Data: Values, types and expressions.

Desktop Command window

Lecture 2 Selection and Looping. Program control, if-else, logical expressions, for loop

Introduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan

VARIABLES & ASSIGNMENTS

Basic Programming Language Syntax

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

Dr. Khaled Al-Qawasmi

VBScript: Math Functions

Course Layout. Go to follow instr. Accessible within campus (only for the first download)

Chapter 1: An Overview of MATLAB

Programming in Mathematics. Mili I. Shah

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

The purpose of this lesson is to familiarize you with the basics of Racket (a dialect of Scheme). You will learn about

Introduction to MATLAB

McTutorial: A MATLAB Tutorial

Course Outline. Introduction to java

9. Elementary Algebraic and Transcendental Scalar Functions

Lecture 3 (02/06, 02/08): Condition Statements Decision, Operations & Information Technologies Robert H. Smith School of Business Spring, 2017

egrapher Language Reference Manual

Computer Programming ECIV 2303 Chapter 1 Starting with MATLAB Instructor: Dr. Talal Skaik Islamic University of Gaza Faculty of Engineering

Lab 1 Intro to MATLAB and FreeMat

ENGR 1181 MATLAB 05: Input and Output

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh

Transcription:

Step by step set of instructions to accomplish a task or solve a problem

Algorithm to sum a list of numbers: Start a Sum at 0 For each number in the list: Add the current sum to the next number Make the result the new Sum The result is the final value of Sum

Example: sum Let Sum = 0 Add 8 + 7 = 15 Add 0 + 5 = 5 Let sum = 15 Let sum = 5 Add 15 + 2 = 17 Add 5 + 3 = 8 Let sum = 17 Let sum = 8 Result:

Step by step set of instructions to accomplish a task or solve a problem

a word already defined in the language. Includes known symbols: These may NOT be re-defined by the programmer. etc.

a word defined by the programmer - must begin with a letter - remainder may be made up of letters, numbers or the underscore - NOTE: no spaces! - these are usually the Names of things

a word that IS (literally) a data value 3-7 12.5 Go Big Blue!! (character data between Single quotes)

anything on a line after a percent sign - Comments have NO EFFECT on a program and are not seen by the User. - Purpose: to add explanatory notes by programmers, for programmers.

for writing statements, defined by the language. Failure to follow these rules results in a and the program will not execute (run).

the of a statement What does it do? What does it command the computer to do?

for writing a statement in a program. - Failure to follow these rules has NO EFFECT on the program or what it does. - These rules make the program clearer to a programmer. - Examples: using comments, using meaningful identifier names, indentation and spacing.

for data in a program A Variable has a: - an identifier - a description of the data it contains (ex: number, string, matrix) - : which can change during execution.

% my first Matlab program width = 20; height = 30; area = width * height; disp(area); % the semicolons suppress Matlab clutter % when RUN (executed), this program % prints

Syntax: = must be a single variable, nothing else can be: - a literal - another variable (including ) - a function call - an expression made up of any of the above combined with operators ( etc.)

Semantics: = 1. is evaluated to one value. 2. The Value of is changed to the evaluated result of. Read as The value of is changed to Style: usually, all on one line.

Examples: x = 1 y = ((2+1)*(3/5))^2 x = x + 1 % think: Add 1 to x y = x * 2 z = sqrt(16) % sqrt() is the % Square Root function 2 + 3 = x % Syntax Error!

Standard: Power: 3^2 is 9 Modulus: mod(9,4) is 2 Remainder: rem(9,4) is 1 Negation: x = 2 y = -x y becomes -2 Round Off: round(2.5) is 3 Square Root: sqrt(16) is 4

Syntax: disp( ) Semantics: evaluates and displays the result on the command window. Then advances the cursor to the next line. Style: usually all on one line

Examples: disp(3) prints x = 6 disp(x*2) prints y = 'Hello World' disp(y) prints without the quotes!

The number must be converted to string, then appended to the string portion x = 6 disp( 'The answer is ' x ) Prints:

= input( ) Syntax: use the input() function on the Right Hand Side of an Assignment. is the question to display to the user, called a will hold the value entered by the user.

= input( ) Semantics: 1. The is printed in the command window. 2. Execution is suspended; it waits for the user to respond. 3. The user enters a value and presses. 4. The value entered is evaluated, and the result is assigned to the

Example: n = input( Enter a number: ) m = 2 * n disp([num2str(n), doubled is, num2str(m)]) If the user enters 3, it prints:

String Input is slightly different. When the user is expected to enter a string value, a second argument of 's' must be used in input: name = input('enter name: ' ) disp('hello ',name,'! How are you?')

It is usually a good idea to start all scripts by clearing the screen and workspace: clc; % clears the screen clear; % drops all variables

Term Algorithm Program Keyword Reserved Word Identifier Literal Comment Syntax Semantics Style Variable Data Type String Definition a step by step set of instructions to accomplish a task a step by step set of instructions to accomplish a task, written in a computer language word that has an already-defined meaning in a computer language. word that has an already-defined meaning in a computer language. word defined by a programmer, usually the Name of something. something that IS a value. Ex: 8 12.5 Hello anything on a line after a %. It has NO EFFECT on the program rules for writing statements in a computer language that must be followed for the computer to understand/interpret/execute the command. meaning of a statement in a program; what it causes the computer to do rules for writing statements in a computer language that have NO EFFECT on the program, but make the program clearer for programmers. a container for data, which has a Name, Data Type, and Value which can change. a Description of the data held by a variable. ex: numeric, string, matrix Data Type that describes a sequence of any characters. Literals are between single quotes.