MATLAB: Anonymous functions with 2 ou more outputs

anonymous functions

Hi,
I would like to know if it's possible to program an anonymous function with more than one output WITHOUT using another already defined function that have more than 1 output (I know this is actually possible). I need to program an anonymous function which takes a matriz with P+Q columns and "breaks" it in 2 matrixes: A and B, where A has P columns and B has Q columns. So the function output would be [A, B]. It'd really help me.
Thanks in advance, Guilherme

Best Answer

m=[1 2;3 4;5 6]
fcol=@(x)deal(x(:,1),x(:,2))
[a b]=fcol(m)
In this simple case you only got 2 columns but you can expand it to multiple columns.
m=[1 2 3 4;5 6 7 8;9 10 11 12]
fcol=@(x)deal(x(:,1:2),x(:,3:4))
[a b]=fcol(m)