02.03.2016 Views

MATLAB by rudra pratap

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

• Errors<br />

Errors are an integral part of life whether you interact with computers or not. The<br />

only difference is, when you interact with computers, your errors are pointed out<br />

immediately-often bluntly and without much advice. Interaction with <strong>MATLAB</strong><br />

is no exception. Yes, to err is human, but to forgive is definitely not <strong>MATLAB</strong>ine.<br />

So, the earlier you get used to the blunt manners of your friend and his terse<br />

comments, the better for you. As this friend does not offer much advice most of the<br />

time, we give you some hints here based on our own experience in dealing with your<br />

friend. Before we begin, we warn you that this friend has a tendency to become<br />

very irritating if you work under too much time pressure or don't have enough sleep.<br />

In particular, if you are not relaxed enough to distinguish between ( and [, ; and<br />

: , or a and A, you and your friend are going to have long sessions staring at each<br />

other.<br />

Here are the most common error messages that you are likely to get while working<br />

in <strong>MATLAB</strong>. All messages below are shown following a typical command. Following<br />

the actual message are explanations and tips.<br />

1 . »D = zeros (3) ; d = [1 2 ];<br />

» D(2.:3, :) = s in ( d)<br />

??? Subscrip ed. assi.gnment d.:IT.l..B.sio.n<br />

This is a typical problem in matrix assignments where the dimensions of the<br />

matrices on the two sides of the equal sign do not match. Use the size<br />

command to check the dimensions on both sides and make sure they agree. For<br />

example, for the preceding command to execute properly, size (D (2: 3, : ) )<br />

and size (sin(d) ) or size(d) must give the same dimensions.

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

Saved successfully!

Ooh no, something went wrong!