From: ade77 on 8 Jan 2010 15:04 Example I have the array : A = [ 1 2 3; 4 5 6; 7 8 9] I want a cell array of 3 by 1: MyCell = {1 2 3 4 5 6 7 8 9} Meaning, I have an array of m by n, and I want my cell array to be m by 1
From: us on 8 Jan 2010 15:18 "ade77 " <ade100a(a)gmail.com> wrote in message <hi833k$hbe$1(a)fred.mathworks.com>... > Example I have the array : > A = [ 1 2 3; 4 5 6; 7 8 9] > > I want a cell array of 3 by 1: > MyCell = {1 2 3 > 4 5 6 > 7 8 9} > > Meaning, I have an array of m by n, and I want my cell array to be m by 1 a hint: help num2cell; us
From: Andy on 8 Jan 2010 15:24 "ade77 " <ade100a(a)gmail.com> wrote in message <hi833k$hbe$1(a)fred.mathworks.com>... > Example I have the array : > A = [ 1 2 3; 4 5 6; 7 8 9] > > I want a cell array of 3 by 1: > MyCell = {1 2 3 > 4 5 6 > 7 8 9} > > Meaning, I have an array of m by n, and I want my cell array to be m by 1 B=mat2cell(A,[1 1 1],3);
From: Nathan on 8 Jan 2010 15:29 On Jan 8, 12:04 pm, "ade77 " <ade1...(a)gmail.com> wrote: > Example I have the array : > A = [ 1 2 3; 4 5 6; 7 8 9] > > I want a cell array of 3 by 1: > MyCell = {1 2 3 > 4 5 6 > 7 8 9} > > Meaning, I have an array of m by n, and I want my cell array to be m by 1 You wrote that wrong, then. If you execute the code you supplied for MyCell, you will receive a 3x3 cell array. If you wanted [1 2 3] to be the first row and consist of only one column, you need to write it as such: MyCell = {[1 2 3];[4 5 6];[7 8 9]} %%%%%%%%%%%%%%%%%%%%% whos MyCell Name Size Bytes Class Attributes MyCell 3x1 252 cell Anyways... One way to do so is as follows: for i=1:size(A,1) MyCell(i,1) = {A(i,:)}; end %%%%%%%%%%%%%%%%%%%%% whos MyCell Name Size Bytes Class Attributes MyCell 3x1 252 cell It probably isn't the most efficient way, but it works. -Nathan
From: us on 8 Jan 2010 15:37 "Andy " > B=mat2cell(A,[1 1 1],3); -or- slightly more user friendly... b=num2cell(a,2); us
|
Next
|
Last
Pages: 1 2 Prev: viewing a plane down it's normal vector Next: change background color of a polar plot |