23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Message Identifiers<br />

case 'myfileio:noaccess'<br />

error('DisplayImg:noaccess', ...<br />

['Can''t open file "%s" for reading\n', ...<br />

'You may not have read permission.'], filename);<br />

case 'myfileio:invformat'<br />

error('DisplayImg:invformat', ...<br />

'Unable to determine the file format.');<br />

end<br />

end<br />

If the last error has no message identifier tag associated with it, then<br />

<strong>MATLAB</strong> returns an empty string in the identifier field:<br />

error('This error has no message identifier.');<br />

??? This error has no message identifier.<br />

err = lasterror;<br />

err.identifier<br />

ans =<br />

''<br />

Inputs to lasterror<br />

In addition to returning information about the last error, lasterror also<br />

accepts inputs that modify the <strong>MATLAB</strong> copy of the last error. Use the<br />

command format shown below to change the error message string and<br />

message identifier returned by subsequent invocations of lasterror.<br />

err.message = 'new_errmsg';<br />

err.identifier = 'comp:new_msgid';<br />

last = lasterror(err)<br />

last =<br />

message: 'new_errmsg'<br />

identifier: 'comp:new_msgid'<br />

stack: [0x1 struct]<br />

8-13

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!