Skip to main content

5.1) Elementary Matrices


Matlab has a number of built-in functions to create matrices.

[matlab]
>> e=zeros(3,3); % creates a 3x3 matrix full of zeros
>> f=ones(3,3); % creates a 3x3 matrix full of ones
>> g=eye(3,3); % creates a 3x3 identity matrix
>> h=rand(3,3); % creates a 3x3 matrix of random numbers (between 0 and 1)
>> k=randn(3,3); % creates a 3x3 matrix of normally distributed random numbers
[/matlab]