annotate general/arrutils/maprows.m @ 54:9bcf5e133bf0
Added from old stats library.
author |
samer |
date |
Mon, 23 Feb 2015 16:08:09 +0000 |
parents |
fbc0540a9208 |
children |
|
rev |
line source |
samer@4
|
1 function Y=maprows(f,X)
|
samer@4
|
2 % maprows - Map a function of a vector over the rows of an array
|
samer@4
|
3 %
|
samer@4
|
4 % maprows ::
|
samer@4
|
5 % ([[1,N]->A] -> [[1,M]->B]) ~'function maps a row of A to a row of B',
|
samer@4
|
6 % [[L,N]->A]
|
samer@4
|
7 % -> [[L,M]->B].
|
samer@4
|
8
|
samer@4
|
9 n=size(X,1);
|
samer@4
|
10 if n==0, Y=[];
|
samer@4
|
11 else
|
samer@4
|
12 for i=n:-1:1
|
samer@4
|
13 Y(i,:)=f(X(i,:));
|
samer@4
|
14 end
|
samer@4
|
15 end
|
samer@4
|
16
|