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).
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!
>
"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.'
> 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.
"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 " <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
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Disclaimer prior to use.