14.09.2015 Views

Matvec Users’ Guide

Matvec Users' Guide

Matvec Users' Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

3.4. COMPUTATION 25<br />

max<br />

A.max() returns a vector whose each element is the largest element of each column of A. If A is a one-row<br />

or one-column matrix, then the returned value would be a scalar.<br />

If both A and B are matrices (one of them could be a scalar), then A.max(B) returns a matrix of the<br />

same size as A or B with resulting element(i,j) being the largest element among A(i,j) and B(i,j).<br />

For example,<br />

> A=sample(2,2)<br />

Col 1 Col 2<br />

Row 1 0.0100414 0.578454<br />

Row 2 0.973198 0.792847<br />

> B=sample(2,2)<br />

Col 1 Col 2<br />

Row 1 0.619559 0.927987<br />

Row 2 0.89682 0.990276<br />

> A.max()<br />

i = 1 i = 2<br />

0.973198 0.792847<br />

> A.max(B)<br />

mean<br />

Col 1 Col 2<br />

Row 1 0.619559 0.927987<br />

Row 2 0.973198 0.990276<br />

A.mean() returns a vector containing average values for each column of A. If A is a one-row or one-column<br />

matrix, then the returned value would be a scalar.<br />

min<br />

A.min() returns a vector whose each element is the smallest element of each column of A. If A is a one-row<br />

or one-column matrix, then the returned value would be a scalar.<br />

If both A and B are matrices (one of them could be a scalar), then A.min(B) returns a matrix of the<br />

same size as A or B with resulting element(i,j) being the smallest element among A(i,j) and B(i,j).<br />

For example,<br />

> A=sample(2,2)<br />

Col 1 Col 2<br />

Row 1 0.0100414 0.578454<br />

Row 2 0.973198 0.792847<br />

> B=sample(2,2)<br />

Col 1 Col 2<br />

Row 1 0.619559 0.927987<br />

Row 2 0.89682 0.990276<br />

> A.min()<br />

i = 1 i = 2<br />

0.0100414 0.578454

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

Saved successfully!

Ooh no, something went wrong!