A
is an array, what is A(3,4)
?A
is an array, how to access its third row?We already studied the concept of arrays/matrices.
A 1-dimensional array can be created by listing the entries within a pair of square brackets:
a = [1 2 3 4]
A 2-dimensional array can be created in a similar way with semi-colon used as row separator (line break is fine too).
a = [1 2 3; 4 5 6; 7 8 9]
a = 3:9
a = 3:0.5:9
a = zeros(3,4)
a = ones(3,4)
a = rand(3,4)
a = true(3,4)
a = false(3,4)
Equally space points are often useful in applications.
a = linspace(0,10,30)
a = logspace(0,3,30)
[X,Y] = meshgrid(x,y)
length(A)
size(A)
ndims(A)
A(3,:)
A(:,3)
A(1:3,2)