Graphics Programs Reference
In-Depth Information
To raise the elements of a matrix to a power use the
.^
operator:
>> a = pascal(3)
a=
1
1
1
1
2
3
1
3
6
>> a.^2
ans =
1
1
1
1
4
9
1
9
36
6 Basic Data Analysis
The following functions can be used to perform data analysis functions:
max
maximum
min
minimum
find
find indices of nonzero elements
mean
average or mean
median
median
std
standard deviation
sort
sort in ascending order
sortrows
sort rows in ascending order
sum
sum of elements
prod
product of elements
diff
difference between elements
trapz
trapezoidal integration
cumsum
cumulative sum
cumprod
cumulative product
cumtrapz
cumulative trapezoidal integration
As we have seen with the
plot
command, matlab usually prefers to
work with matrix columns, rather than rows. This is true for many of
matlab's functions, which work on columns when given matrix argu-
ments. For example:
>> a = magic(3)
a=
8
1
6
3
5
7
4
9
2
>> m = max(a)
m=
8
9
7