1 Programming with MATLAB ผศ. ดร. อนันต์ ผลเพิ่ม Anan Phonphoem

Slides:



Advertisements
Similar presentations
Chapter 3: Modularization
Advertisements

Chapter 2 - Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 2 - Problem Solving
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
INTRODUCTION TO PROGRAMMING
Chapter 2- Visual Basic Schneider
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Program Flow Charting How to tackle the beginning stage a program design.
Chapter 2: Input, Processing, and Output
Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved.
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Chapter 1 Program Design
Problem Solving Chapter 2. What is an algorithm? n A solution to a problem that is: –Precise –Effective –Terminating.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
Chapter 3 Planning Your Solution
BPC.1 Basic Programming Concepts
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Chapter 1 Pseudocode & Flowcharts
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Chapter 2: Developing a Program Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 1 Chapter 2 Developing.
Structured COBOL Programming, Stern & Stern, 9th edition
CS 0004 –Lecture 8 Jan 24, 2011 Roxana Gheorghiu.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 2.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Practice and Evaluation. Practice Develop a java class called: SumCalculator.java which computes a sum of all integer from 1 to 100 and displays the result.
CPS120 Introduction to Computer Programming The Programming Process.
ENGR-25_Programming-1.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Registered Electrical.
Cs413_design04.ppt Design and Software Development Design : to create a functional interface that has high usability Development : an organized approach.
The basics of the programming process The development of programming languages to improve software development Programming languages that the average user.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
1 Program Planning and Design Important stages before actual program is written.
1 Pertemuan 25 Bahasa-bahasa Pemrograman Matakuliah: T0604-Pengantar Teknologi Informasi Tahun: 2008 Versi: 2.0/0.0 Williams, B.K, Stacy C. Sawyer (2007).
1 Programming Tools Flowcharts Pseudocode Hierarchy Chart Direction of Numbered NYC Streets Algorithm Class Average Algorithm.
The Art of Programming. The process of breaking problems down into smaller, manageable parts By breaking the problem down, each part becomes more specific.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
1 Conditional Statements + Loops ผศ. ดร. อนันต์ ผลเพิ่ม Anan Phonphoem
The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Lecture 2 Debugging,
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
Computers and Programming ผศ. ดร. อนันต์ ผลเพิ่ม Anan Phonphoem
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Flowcharts C++ Lab. Algorithm An informal definition of an algorithm is: a step-by-step method for solving a problem or doing a task. Input data A step-by-step.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Program Program is a collection of instructions that will perform some task.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
Program Design & Development EE 201 C7-1 Spring
Integrating Algorithms and Coding into the Mathematics Classroom
Program design Program Design Process has 2 phases:
Chapter 2: Input, Processing, and Output
Chapter 2- Visual Basic Schneider
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Algorithm Algorithm is a step-by-step procedure or formula or set of instruction for solving a problem Its written in English language or natural language.
Unit# 9: Computer Program Development
Problem Solving Techniques
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Chapter 2- Visual Basic Schneider
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 2- Visual Basic Schneider
Basic Concepts of Algorithm
Introduction to Programming
Presentation transcript:

1 Programming with MATLAB ผศ. ดร. อนันต์ ผลเพิ่ม Anan Phonphoem

2 Operation modes in MATLAB Interactive mode (calculator mode) Script file (computer program) >>a+b ans = [ 3 15 ] >>a+b ans = [ 3 15 ] %Example of program %Program Test1.m a = [ 1 10]; b = [ 2 5]; c = a + b %Example of program %Program Test1.m a = [ 1 10]; b = [ 2 5]; c = a + b

3 Some key words in programming Algorithm Structured Programming Top-down design (programming strategy) Documentation Pseudocode

4 Algorithms Algorithm Ordered sequence of instructions Perform some task in a finite time 3 types of Algorithm Sequential operation Conditional operation Iterative (loop) operation

5 Structured programming Compose of hierarchy of modules (functions) Clear program flow Sequential, Conditional, Iterative No unnecessary branches No “ goto ” in BASIC

6 Advantage of structured program Easy to write and understand Concentrate on the overall problem first Solve problem in divide and conquer style Easy to debug Easy to modify Reusable Modules (functions) Teamwork environment Each person takes care some certain modules

7 Top-down design (Programming Strategy) Don ’ t rush to key in the computer State the problem concisely (Think carefully) Specify “ input ” and “ output ” Solve the problem “ by hand ” Plan your program (module, sequence, etc.) Test by hand if possible “ Writing and Running ” program “ Testing and Debug ” program (sample input) Documentation Maintenance

8 Developing structured programming Charts Structure chart Flowchart

9 Structure Chart Initial state of top-down design Describe the connection between parts (modules) No (calculation) details

10 Structure chart example Writing a game “ Tic-Tac-Toe ” Main Program Player Input (User interface) Player Input (User interface) Game Status (Board display) Game Status (Board display) Strategy Module

11 Start Flowchart Show sequence and branches End Read width,length If total 0 Write total No Yes Total := width + length

12 Documentation Very Important for understand/debug/modify Good documentation Proper selection of variable names Use of comments within the program Use of structure charts Use of flowcharts Use verbal description (pseudocode)

13 Pseudocode To describe program in short and understandable Imitation code (not a real code) Outlining a program (before detailed coding) Use natural language Mathematical expression No detailed syntax

14 Pseudocode Example 1.Enter x and y coordinates 2.Compute the z 3.Check for valid output (>= 0) 4.Display the result 5.Stop z = √ (x 2 +y 2 ) To calculate

15 Exercise Writing a “ เป่า ยิง ฉุบ ” program Structure Chart Flowchart or Pseducode