From: Catalin Eberhardt on
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
The title of my post should be "Individual elements of an array withIN a cell", unfortunately cannot edit it...
From: someone on
"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
Yes I now see there is more than way of doing this, thanks! :)
From: Walter Roberson on
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} .