I need to apply a function over columns of a matrix. Let's say I have this matrix --
>> m = rand(3,3)
m =
0.8626 0.5661 0.8489
0.6830 0.1498 0.1401
0.0857 0.4775 0.3296
and two vectors of lower and upper bounds --
>> mins = [2 3 5]
mins =
2 3 5
>> maxs = [7 11 13]
maxs =
7 11 13
Now what I am doing is to split the matrix into columns --
>> cols = num2cell(m, 1)
cols =
[3x1 double] [3x1 double] [3x1 double]
Now what I was trying is to apply a function over each column that takes the lower and the upper bounds to normalize the column values, more specifically I want to normalize the column m(:,1) with mins(1) and maxs(1), m(:,2) with mins(2) and maxs(2) ... column m(:,n) with mins(n) and maxs(n) and so on. My take was like this --
>> norm_cols = cellfun(@(c, lb, ub) (ub - lb) .* c + lb, cols, mins, maxs);
Error using cellfun
Input #3 expected to be a cell array, was double instead.
My question is such thing doable in matlab? and lets say it's doable, then how do I merge the splitted columns into matrix again?
Moreover, please note that I am aware of loops, but I do not want to use it (as my matrix can grow like 1000x1000), so please do not provide any solution that uses loop. Although I am not sure if function mapping could give better speed up than loops (that's another issue, but not for today).
min + (max - min) * xover each value in columns. - ramgorur