1 / 4

Dealing with Error Messages in Matlab

Dealing with Error Messages in Matlab. The topmost error message is usually the one containing the most useful information The underlined parts of the message are actually links that you can click to get to the line where the error happened!. How the Matlab-Editor can help you.

liona
Download Presentation

Dealing with Error Messages in Matlab

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Dealing with Error Messages in Matlab • The topmost error message is usually the one containing the most useful information • The underlined parts of the message are actually links that you can click to get to the line where the error happened! Daniel Baur / Introduction to Matlab Part III

  2. How the Matlab-Editor can help you Red: There is a fatal syntax error that will prevent proper execution Mouse-over the markers to see what’s wrong; the lines on the right are actual clickable links Orange: There is unusual syntax that may slow down the code or produce unexpected results (possible semantic error) Green: The code is fine from a syntax point of view (it can still contain semantic errors!) Daniel Baur / Numerical Methods for Chemical Engineers / Numerical Quadrature

  3. Programming Tips for Matlab • The main executable should be a script, not a function • If you use a function, the workspace will be empty after execution. This means that you cannot check any variables or work with them. • Use clear all; close all; (and optionally clc) at the beginning of your scripts • This prevents left-over variables and plots from producing unexpected results • Use variable loop bounds when looping over a vector • If there is a vector z = linspace(0, 100);and you want to loop over it, use a for loop of the form for i = 1:length(z). That way, you won’t have to change the loop bounds if want to change the length of z. Daniel Baur / Numerical Methods for Chemical Engineers / Numerical Quadrature

  4. Programming Tips for Matlab • Preallocate variables before loops, i.e. fill them with zeros • This will vastly speed up your code, especially with larger operations Daniel Baur / Numerical Methods for Chemical Engineers / Numerical Quadrature

More Related