- arrayfun():
arrayfun(func,A1,...,An) // func是函数句柄,对A1,……,An的元素进行func函数运算,并返回结果。
s=[1 2;3 4];
arrayfun(@(x)x^2,s)
ans=
1 4
9 16
- polyval():
y = polyval(p,x) // p 是向量,构成一个多项式系数,然后计算此多项式在x处的函数值,x可以是向量。
p = [3 2 1]
polyval(p,[5 7 9])
ans =
86 162 262
sub2ind():
- linearInd = sub2ind(maxtrixSize, rowSub, colSub) // 返回一个矩阵中由 rowSub 和 colSub确定的元素的线性索引。
x =
9 7 10 10
10 1 10 5
2 3 2 9
10 6 10 2
>> x([1,3],[2,4])
ans =
7 10
3 9
>> ind=sub2ind(size(x),[1,3,1,3],[2,2,4,4])
ind =
5 7 13 15
>> x(ind)
ans =
7 3 10 9
ind2sub():
- [row,col] = ind2sub(size,IND) // size是矩阵的维度大小,如【3,4】;IND是要找的线性维索值。返回所要找的元素值 //的高维索引
>> IND = [3 4 5 6]
>> s = [3,3]
>> [I,J] = ind2sub(s,IND)
I =
3 1 2 3
J =
1 2 2 2