EGR 115 Introduction to Computing for Engineers MATLAB Basics 6: Debugging in MATLAB Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers.

Slides:



Advertisements
Similar presentations
Introduction to Matlab
Advertisements

Debugging in Matlab C. Reed 4/5/11. Bugs Debugging is a natural part of programming: Three standard types of errors: –Syntax errors: you simply have typed.
Flow Charts, Loop Structures
General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009.
Introduction to Matlab By: Dr. Maher O. EL-Ghossain.
General Computer Science for Engineers CISC 106 Lecture 04 Roger Craig Computer and Information Sciences 9/11/2009.
Get number The ginput command creates crosshairs. When the user clicks the x,y values of the crosshairs are returned.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 4: Enhancing Your Program.
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Introduction to MATLAB
DEBUGGERS For CS302 Data Structures Course Slides prepared by TALHA OZ (most of the text is from
Chapter 1: Introduction To Computer | SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005 Slide 1 Introduction To Computers.
6 Steps of the Programming Process
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
19/5/2015CS150 Introduction to Computer Science 1 Announcements  1st Assignment due next Monday, Sep 15, 2003  1st Exam next Friday, Sep 19, 2003  1st.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
Introduction to MATLAB. Windows in MATLAB Command Window – where you enter data, run MATLAB code, and display results Command History - displays a log.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
Eng Ship Structures 1 Introduction to Matlab.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
ME 142 Engineering Computation I Debugging Techniques.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Structured Programming: Debugging and Practice by the end of this class you should be able to: debug a program using echo printing debug a program using.
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
CSE 351 GDB Introduction. Lab 1 Status? How is Lab 1 going? I’ll be available at the end of class to answer questions There are office hours later today.
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 4: Intro to Plotting Wednesday 10 Sept 2014 EGR 115 Introduction to Computing for Engineers.
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.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 2: Sub-Arrays Friday 05 Sept 2014 EGR 115 Introduction to Computing for Engineers.
EGR 115 Introduction to Computing for Engineers Branching & Program Design – Part 1 Monday 29 Sept 2014 EGR 115 Introduction to Computing for Engineers.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Introduction to Testing CSIS 1595: Fundamentals of Programming and Problem Solving 1.
EGR 115 Introduction to Computing for Engineers Designing The Battleship Game in MATLAB Monday 22 Sept 2014 EGR 115 Introduction to Computing for Engineers.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 3: Array Operations Monday 08 Sept 2014 EGR 115 Introduction to Computing for Engineers.
School of Computer Science & Information Technology G6DICP - Lecture 6 Errors, bugs and debugging.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 5: Applications – Vector Math Friday 12 Sept 2014 EGR 115 Introduction to Computing for Engineers.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 1: Variables & Arrays Wednesday 03 Sept 2014 EGR 115 Introduction to Computing for Engineers.
The Hashemite University Computer Engineering Department
5.01 Understand Different Types of Programming Errors
The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Lecture 2 Debugging,
EGR 115 Introduction to Computing for Engineers Loops and Vectorization – Part 1 Monday 13 Oct 2014 EGR 115 Introduction to Computing for Engineers.
EGR 115 Introduction to Computing for Engineers Branching & Program Design – Part 4 Monday 06 Oct 2014 EGR 115 Introduction to Computing for Engineers.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
EGR 115 Introduction to Computing for Engineers Loops and Vectorization – Part 3 Friday 17 Oct 2014 EGR 115 Introduction to Computing for Engineers.
Chapter 4 MATLAB Programming MATLAB Troubleshooting Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
1 Project 4: Computing Distance. 222 Computing Distance Write a program to compute the distance between two points. Recall that the distance between the.
COMPUTER PROGRAMMING I SUMMER Understand Different Types of Programming Errors.
Debugging M-Files Steve Gu Feb 08, Outline What’s Debugging? Types of Errors Finding Errors Debugging Example Using Debugging Features.
Structured Computer Programming EE 201 Introduction to MATLAB 7 for Engineers بسم الله الرحمن الرحيم King Abdulaziz University College of Engineering Dept.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
Harvard Mark I Howard Aiken was a pioneer in computing and a creator of conceptual design for IBM in the 1940s. He envisioned an electro-mechanical computing.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
Wrapper Classes Debugging Interlude 1
ME 142 Engineering Computation I
EGR 115 Introduction to Computing for Engineers
Introduction to MATLAB
Chapter 4 MATLAB Programming
Outline Matlab tutorial How to start and exit Matlab Matlab basics.
Debugging 9/22/15 & 9/23/15 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Introduction to MATLAB
Using Script Files and Managing Data
ME 123 Computer Applications I Lecture 5: Input and Output 3/17/03
Presentation transcript:

EGR 115 Introduction to Computing for Engineers MATLAB Basics 6: Debugging in MATLAB Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers

Lecture Outline Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers Debugging in MATLAB Symbolic calculations in MATLAB Publishing a file in MATLAB Slide 2 of 13

MATLAB basics Debugging in MATLAB Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers Most human beings occasionally make errors Program errors are often referred to as “bugs” Debugging refers to the process of eradicating “bugs” There are three general classes of programming errors Slide 3 of 13

MATLAB basics Debugging in MATLAB – Syntax Errors Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers Types of programming errors  Syntax Error – What students tend to think of when you mention bugs. Found (& reported) by command window or compiler. Frequently typos!!  Examples: >> Cos(pi)  The name of the MATAB function for Cosine is “cos(…)” NOT “Cos(…)” o A(1)) = 5; Slide 4 of 13

MATLAB basics Debugging in MATLAB – Syntax Errors Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers  Syntax errors can typically be resolved by carefully reviewing the error message o Sometimes the interpreter will make suggestions on how to fix the problem!! >> A = o The response is not always precise Slide 5 of 13

MATLAB basics Debugging in MATLAB – Run-time Errors Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers  Run-time Error – Error which is reported when the program is executed. Divide by zero, or multiply by ‘string’, … o Arithmetic type Run-Time Error: >> log10(0) o Indexing type Run-Time Error: >> a = [ ]; >> b = a(4) Slide 6 of 13

MATLAB basics Debugging in MATLAB – Run-time Errors Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers o Assignment type Run-Time Error: >> a = [ ]; >> b = ones(3, 1); >> c = a + b;  “a” is a 1x3 row vector and “b” is a 3x1 column vector, hence, they are not compatible under addition!! Slide 7 of 13

MATLAB basics Debugging in MATLAB – Logical Errors Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers  Logical Error – Hardest error to find, not reported, program runs without reported error, but produces erroneous results. o We wish to test if the class should be over:  Check to see if the time is greater or equal to 4 pm. >> Time = clock;% Obtain current year, month, date, hr, min, sec >> if (Time(4) <= 4 ) % Check to see if after 4pm >> disp('Class should be over'); % If after 4pm display the statement >> end We made another logical error!! The hour variable is in 24 hr format => 4pm = 16 We made another logical error!! The hour variable is in 24 hr format => 4pm = 16 We made a logical error!! Should be >= not <= !!! We made a logical error!! Should be >= not <= !!! Slide 8 of 13

MATLAB basics Debugging in MATLAB Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers MATLAB Debugger  Breakpoints o Allows the controlled step-by-step execution of code  Examining contents of variables  Escaping a “run-away” program o CTRL-C Use example of “Hwk1_Soln.m” Slide 9 of 13

MATLAB basics Symbolic Calculations in MATLAB Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers MATLAB can perform symbolic calculations  The Symbolic toolbox >> syms t >> y = sin(t) >> diff(y, t) Define “t” as a symbolic variable Slide 10 of 13

MATLAB basics Publishing a file in MATLAB Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers MATLAB can “publish” the results of executing a *.m file  Will include plots and results of calculations Slide 11 of 13

MATLAB basics Publishing a file in MATLAB Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers  Set the “Output file format” to “doc” before publishing o Input commands will not be processed  Comment “input(…)” related lines or hardcode the input Use example of “Hwk2_Soln.m” Slide 12 of 13

Next Lecture Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers 2D Plotting  Additional features Slide 13 of 13