From: Alek on
Hi all

A problem I'm having is working out how to convert a mat array (say 1x5) to a cell array (1x5 -> NOT 1x1 containing a 1x5). In a loop it is just:

xy=[4 5 6 7 8 9].';
z=cell(6,1)
for i=1:6; z{i}=xy(i); end

z is what I want at the end of it, and the above code will do the job, but, I don't want to use a loop if possible. I tried creating a function handle and calling it:

y=@(x) {x}
x=y(xy)

But I'm either missing some syntax or it does not work as it creates a 1x1 cell containing the 6x1 double.
Is what I'm attempting possible without a loop?
From: Matt Fig on
num2cell(xy)
From: Alek on
"Matt Fig" <spamanon(a)yahoo.com> wrote in message <hnlcjp$c90$1(a)fred.mathworks.com>...
> num2cell(xy)
Matt, thanks.