3.8. Generation of Special Matrices
The following MATLAB commands/functions, which generate special matrices, are often used in engineering computations involving matrices:
zeros(p, q)
It returns a rectangular p × q matrix of all zeros.
Let p = 2 and q = 3, and execute the following commands.
p=2; q=3; A=zeros(p, q)
This will generate a (2 × 3) matrix with all elements equal to zero. The following result will be shown
A = 0 0 0 0 0 0
ones(p, q)
It returns a p × q matrix of all ones.
Let p = 2, q = 3, and execute the following commands.
p=2; q=3; A=ones(p, q)
It will generate a (2 × 3) matrix with all elements equal to one. The following result will be shown:
A = 1 1 1 1 1 1
eye(p, q)
It returns a p × q matrix with ones on the main diagonal and zeros ...
Get MATLAB® and Its Applications in Engineering: [Based on MATLAB 7.5 (R2007b)] now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.