Reputation: 3011
This might be something silly, but basically, I have a function in MATLAB called wavedec
. This function does a wavelet decomposition of a vector.
Now, looking at the documentation, the input of this function must be a vector.
However, what if I have a matrix, and I want to call this function for each column of the matrix? Worst case I can put it into a for-loop, but I was wondering if there was a more elegant way. (Maybe with arrayfun? I dont know).
Thanks.
Upvotes: 1
Views: 112
Reputation: 36710
It is possible using cellfun, you have to convert the matrix to a cell of vectors:
mat2cell(M,size(M,1),ones(size(M,2),1))
Both, cellfun and arrayfun internally work iterative, which means it's not faster than a for loop.
Upvotes: 1