23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Empty Matrices, Scalars, and Vectors<br />

true || []<br />

ans =<br />

1<br />

false && []<br />

ans =<br />

0<br />

Elementwise Operations. Unlike the short-circuit operators, all<br />

elementwise operations on empty matrices are considered valid as long as<br />

the dimensions of the operands agree, or the nonempty operand is scalar.<br />

Element-wise operations on empty matrices always return an empty matrix:<br />

true | []<br />

ans =<br />

[]<br />

Note This behavior is consistent with the way <strong>MATLAB</strong> does scalar<br />

expansion with binary operators, wherein the nonscalar operand determines<br />

thesizeoftheresult.<br />

.<br />

Scalars<br />

Any individual real or complex number is represented in <strong>MATLAB</strong> as a 1-by-1<br />

matrix called a scalar value:<br />

A = 5;<br />

ndims(A)<br />

ans =<br />

2<br />

size(A)<br />

ans =<br />

1 1<br />

% Check number of dimensions in A<br />

% Check value of row and column dimensions<br />

1-47

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

Saved successfully!

Ooh no, something went wrong!