From: Catalin Eberhardt on 7 May 2010 13:05 Say I define a cell array as follows: c = {'Name', 'Surname', grades}; where grades is a numerical vector, defined as follows: grades = [7 8 6 10]; My question is, how can I have c look like this: c = 'Name' 'Surname' 7 8 6 10] instead of like this, as Matlab currently arranges it: c = 'Name' 'Surname' [1x4 double] Many thanks for any help!
From: Catalin Eberhardt on 7 May 2010 13:15 The title of my post should be "Individual elements of an array withIN a cell", unfortunately cannot edit it...
From: someone on 7 May 2010 13:28 "Catalin Eberhardt" <longtalker(a)gmail.com> wrote in message <hs1h8g$m3c$1(a)fred.mathworks.com>... > Say I define a cell array as follows: > > c = {'Name', 'Surname', grades}; > > where grades is a numerical vector, defined as follows: > > grades = [7 8 6 10]; > > My question is, how can I have c look like this: > > c = > 'Name' 'Surname' 7 8 6 10] > > instead of like this, as Matlab currently arranges it: > > c = > 'Name' 'Surname' [1x4 double] > > Many thanks for any help! % I'm not sure you can display as you would like. % You could use: c{:} ans = Name ans = Surname ans = 7 8 6 10 % if that helps you any.
From: Catalin Eberhardt on 7 May 2010 13:46 Yes I now see there is more than way of doing this, thanks! :)
From: Walter Roberson on 7 May 2010 13:47
Catalin Eberhardt wrote: > Say I define a cell array as follows: > > c = {'Name', 'Surname', grades}; > > where grades is a numerical vector, defined as follows: > > grades = [7 8 6 10]; > > My question is, how can I have c look like this: > > c = 'Name' 'Surname' 7 8 6 10] > > instead of like this, as Matlab currently arranges it: > > c = 'Name' 'Surname' [1x4 double] You cannot, other than by overriding the display method for cell arrays. If you were to use c = {'Name', 'Surname', num2cell(grades)}; then c would display as 'Name' 'Surname' [7] [8] [6] [10] but then you would have to access [c{3:end}] to get the grades instead of only having to use c{3} . |