Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
exporting cell and double

Subject: exporting cell and double

From: Jessica

Date: 12 Jun, 2008 02:52:01

Message: 1 of 6

Hi,

I have two columns of values:

A=
‘a’
‘b’
‘c’
.
.
.

And

B=
1
2
3
.
.
.

Such that ‘A’ is considered as cell and ‘B’ is considered
as double. Is it possible to create one file (that can be
exported to excel) that combines the two columns such that
the final result looks like the following (in which the two
variables are stored in separate columns):

‘a’ 1
‘b’ 2
‘c’ 3

(I haven’t been able to do this because the columns are of
different types).

Thanks!

Subject: exporting cell and double

From: Siddharth Shankar

Date: 12 Jun, 2008 03:35:03

Message: 2 of 6

You mean,... something like this:

>> M = {1 'a'; 2 'b'; 3 'c'}

M =

    [1] 'a'
    [2] 'b'
    [3] 'c'

>> whos
  Name Size Bytes Class Attributes

  M 3x2 390 cell


>> xlswrite('myfile.xls',M)

This works perfectly, you might want to try this and see if
this is what you are looking for.

"Jessica " <jyorzinski@ucdavis.edu> wrote in message
<g2q30h$ftr$1@fred.mathworks.com>...
> Hi,
>
> I have two columns of values:
>
> A=
> ‘a’
> ‘b’
> ‘c’
> .
> .
> .
>
> And
>
> B=
> 1
> 2
> 3
> .
> .
> .
>
> Such that ‘A’ is considered as cell and ‘B’ is considered
> as double. Is it possible to create one file (that can be
> exported to excel) that combines the two columns such
that
> the final result looks like the following (in which the
two
> variables are stored in separate columns):
>
> ‘a’ 1
> ‘b’ 2
> ‘c’ 3
>
> (I haven’t been able to do this because the columns are
of
> different types).
>
> Thanks!
>

Subject: exporting cell and double

From: Jessica

Date: 12 Jun, 2008 17:00:20

Message: 3 of 6

"Siddharth Shankar" <siddharth.shankar@gmail.com> wrote in
message <g2q5h7$b0e$1@fred.mathworks.com>...
> You mean,... something like this:
>
> >> M = {1 'a'; 2 'b'; 3 'c'}
>
> M =
>
> [1] 'a'
> [2] 'b'
> [3] 'c'
>
> >> whos
> Name Size Bytes Class Attributes
>
> M 3x2 390 cell
>
>
> >> xlswrite('myfile.xls',M)
>
> This works perfectly, you might want to try this and see
if
> this is what you are looking for.
>
> "Jessica " <jyorzinski@ucdavis.edu> wrote in message
> <g2q30h$ftr$1@fred.mathworks.com>...
> > Hi,
> >
> > I have two columns of values:
> >
> > A=
> > ‘a’
> > ‘b’
> > ‘c’
> > .
> > .
> > .
> >
> > And
> >
> > B=
> > 1
> > 2
> > 3
> > .
> > .
> > .
> >
> > Such that ‘A’ is considered as cell and ‘B’ is
considered
> > as double. Is it possible to create one file (that can
be
> > exported to excel) that combines the two columns such
> that
> > the final result looks like the following (in which the
> two
> > variables are stored in separate columns):
> >
> > ‘a’ 1
> > ‘b’ 2
> > ‘c’ 3
> >
> > (I haven’t been able to do this because the columns are
> of
> > different types).
> >
> > Thanks!
> >
>

Thanks for this suggestion. This is close to what I need to
do except that 'A' and 'B' are stored variables (and
contain hundreds of values) and I don't want to have to
type them out manually in 'M.'

Subject: exporting cell and double

From: William

Date: 12 Jun, 2008 19:22:01

Message: 4 of 6

> Thanks for this suggestion. This is close to what I need
to
> do except that 'A' and 'B' are stored variables (and
> contain hundreds of values) and I don't want to have to
> type them out manually in 'M.'

If A is a cell array then you may have to convert it to a
character array for this to work right, but you should be
able to do a loop (if you can't figure out the
vectorization of it). This text is assuming you've
unpacked the cell and stored the array as a character
array.

for i=1:1:lenght(A)
NewArray={A(i),B(i)};
end

Subject: exporting cell and double

From: us

Date: 12 Jun, 2008 19:54:02

Message: 5 of 6

"Jessica ":
<SNIP creating output from mixed contents

one of the solutions

     a={
          'a'
          'bb'
          'ccc'
     };
     b=(1:3).';
     m=[a,num2cell(b)]
%{
     m =
     'a' [1]
     'bb' [2]
     'ccc' [3]
%}
% now, put it into an excel sheet, eg,
% xlswrite(fnam,m);
% there will be two cols with the contents of <a> and <b>

us

Subject: exporting cell and double

From: Jessica

Date: 12 Jun, 2008 23:56:02

Message: 6 of 6

"us " <us@neurol.unizh.ch> wrote in message
<g2rusq$dg6$1@fred.mathworks.com>...
> "Jessica ":
> <SNIP creating output from mixed contents
>
> one of the solutions
>
> a={
> 'a'
> 'bb'
> 'ccc'
> };
> b=(1:3).';
> m=[a,num2cell(b)]
> %{
> m =
> 'a' [1]
> 'bb' [2]
> 'ccc' [3]
> %}
> % now, put it into an excel sheet, eg,
> % xlswrite(fnam,m);
> % there will be two cols with the contents of <a> and <b>
>
> us


Thanks, that worked!

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us