Wednesday, July 22, 2009

Working with Matrices

This section introduces you to other ways of creating matrices:

Generating Matrices
The load Function
M-Files Concatenation
Deleting Rows and Columns

Generating Matrices
MATLAB provides four functions that generate basic matrices.
zeros All zeros
ones All ones
rand Uniformly distributed random elements
randn Normally distributed random elements

Here are some examples.
Z = zeros(2,4)
Z = 0 0 0 0 0 0 0 0
F = 5*ones(3,3)
F = 5 5 5 5 5 5 5 5 5
N = fix(10*rand(1,10))
N = 9 2 6 4 8 7 4 0 8 4
R = randn(4,4)
R = 0.6353 0.0860 -0.3210 -1.2316
-0.6014 -2.0046 1.2366 1.0556
0.5512 -0.4931 -0.6313 -0.1132
-1.0998 0.4620 -2.3252 0.3792

No comments:

Post a Comment