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.

Slides:



Advertisements
Similar presentations
Why care about debugging? How many of you have written a program that worked perfectly the first time? No one (including me!) writes a program that works.
Advertisements

Programming Types of Testing.
Debugging Techniques1. 2 Introduction Bugs How to debug Using of debugger provided by the IDE Exception Handling Techniques.
Chapter 8 and 9 Review: Logical Functions and Control Structures Introduction to MATLAB 7 Engineering 161.
Debugging Introduction to Computing Science and Programming I.
General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
Finding and Debugging Errors
How to Debug VB .NET Code.
Guidelines for working with Microsoft Visual Studio 6.
ENGR 111A - Spring MatLab – Palm Chapter 4, Part 4 Review and Debugging Class 12.1: Palm Chapters &
JavaScript, Fourth Edition
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
DEBUGGERS For CS302 Data Structures Course Slides prepared by TALHA OZ (most of the text is from
Programming For Nuclear Engineers Lecture 12 MATLAB (3) 1.
Using a Debugger. SWC What is ”debugging”? An error in a computer program is often called a ”bug”… …so, to ”debug” is to find and get rid of errors in.
ASP.NET Programming with C# and SQL Server First Edition Chapter 6 Debugging and Error Handling.
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.
Debugging applications, using properties Jim Warren – COMPSCI 280 S Enterprise Software Development.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
Debugging UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
Tutorial 1SEG7550 Introduction to MATLAB 18 th, SEP
Introduction to MATLAB Session 3 Simopekka Vänskä, THL Department of Mathematics and Statistics University of Helsinki 2011.
2_Testing Testing techniques. Testing Crucial stage in the software development process. Significant portion of your time on testing for each programming.
Debugging in Java. Common Bugs Compilation or syntactical errors are the first that you will encounter and the easiest to debug They are usually the result.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
ME 142 Engineering Computation I Debugging Techniques.
Program Errors and Debugging Week 10, Thursday Lab.
VB – Debugging Tools Appendix D. Why do we need debugging? Every program has errors, and the process of finding these errors is debugging Types of errors.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Making Good Code AKA: So, You Wrote Some Code. Now What? Ray Haggerty July 23, 2015.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
CS Class 05 Topics  Selection: switch statement Announcements  Read pages 74-83, ,
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
1 SEEM3460 Tutorial Compiling and Debugging C programs.
The Software Construction Process. Computer System Components Central Processing Unit (Microprocessor)
A simple classification problem Extract attributes Pattern Pattern recognition decision x C1 C2.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 6: Debugging in MATLAB Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers.
CS12230 Introduction to Programming Lecture 6-2 –Errors and Exceptions 1.
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 Branching & Program Design – Part 4 Monday 06 Oct 2014 EGR 115 Introduction to Computing for Engineers.
COMPUTER PROGRAMMING Year 9 – Unit 9.04 Week 3. Open the Python INTERPRETER Can you use the interpreter to solve these maths problems? 156 add
AVCE ICT – Unit 7 - Programming Session 12 - Debugging.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
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.
Chapter 6 Testing and running a solution. Errors X Three types Syntax Logic Run-time.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
The LC-3 – Chapter 6 COMP 2620 Dr. James Money COMP
The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Lecture 2 Debugging,
Wrapper Classes Debugging Interlude 1
5.01 Understand Different Types of Programming Errors
Programming in visual basic .net Visual Basic Building Blocks
ME 142 Engineering Computation I
Debugging with Clion and GDB
CS1101X Programming Methodology
Can you pick 3 errors from this
Testing and Debugging.
Chapter 2 Assignment and Interactive Input
Debugging CMSC 202.
2_Testing Testing techniques.
Scripts & Functions Scripts and functions are contained in .m-files
Lesson Outcomes Be able to identify differentiate between types of error in programs Be able to interpret error messages and identify, locate.
Using a Debugger 1-Jan-19.
For Tutors Introduce yourself.
Learning Intention I will learn about the different types of programming errors.
Programming for Business Computing Introduction
Presentation transcript:

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 an illegal expression, independent of the values of the variables in the expression. –Run-time errors: logic errors that result in an illegal expression for specific values of the data (harder to fix) –Logic errors that result in the program executing completely, but the answer that they return is incorrect (hardest to fix).

Syntax Error Example An M-file contains: x = 7; y = 8; if x = y x = y$2 else x = y(3 end Running at the command prompt gives: >> temp ??? Error: File: C:\Programs\MATLAB6p5\work\temp.m Line: 3 Column: 6 Assignment statements do not produce results. (Use = = to test for equality.)

Syntax Error Analysis Matlab only reported the first error it found. It gives you a link to the position in the files where the error occurred. It tells you what type of error (assignment statements do not produce results). And it suggests a fix (use == to test for equality).

Runtime Errors x = [ ]; y = magic(2); % subtraction will cause an error - x is 2-D. xn = x – y; ??? Error using ==> minus Matrix dimensions must agree. Error in ==> temp at 4 z = x - y;

Runtime Error Analysis Matlab gives the line number that caused the error (sometimes errors can propagate) – Also gives the reason for the runtime error! Runtime errors can often times be found manually – harder problems rely on the debugger

Logic Errors %print odd numbers from 1 to 10 for i = 1:10 if rem(i,2) == 0 disp(i); end Simple example, but can be very hard to track down Good debugging techniques come in handy here Simple example, but can be very hard to track down Good debugging techniques come in handy here

Debugger Example type modes type edit modes use breakpoints to walk through code – try the keyboard command

Handling Errors Yourself try-catch: – ch.html ch.html

Decent Debugging Tutorials Q6ZRE Q6ZRE /KB/Docs/DebuggingMatlabMfile /KB/Docs/DebuggingMatlabMfile

Additional Resources 2.1%2004c%20Version%20A.ppt