write output to excel

  • Follow


Hi dears,
I am new member of mathgroups,my outputs in matlab are as complex numbers,I want to know how can I write them into an excel file.  
Thanks
Maryam
0
Reply maryam 5/19/2010 9:49:04 AM

"maryam " <maryam_tayefi@yahoo.com> wrote in message <ht0c6g$jqe$1@fred.mathworks.com>...
> Hi dears,
> I am new member of mathgroups,my outputs in matlab are as complex numbers,I want to know how can I write them into an excel file.  
> Thanks
> Maryam

Hey,

store the complex numbers in a matrix and use the 'xlswrite' function.
0
Reply Varun 5/19/2010 10:02:05 AM


"Varun " <var3161@yahoo.co.in> wrote in message <ht0cut$8n9$1@fred.mathworks.com>...
> "maryam " <maryam_tayefi@yahoo.com> wrote in message <ht0c6g$jqe$1@fred.mathworks.com>...
> > Hi dears,
> > I am new member of mathgroups,my outputs in matlab are as complex numbers,I want to know how can I write them into an excel file.  
> > Thanks
> > Maryam
> 
> Hey,
> 
> store the complex numbers in a matrix and use the 'xlswrite' function.

Dear Varun,
Many thanks for your reply, I have already stored the data which are complex number in a matrix but xlswrite function writes the real unit in a excel file only and discards the imaginary unit. What can I do to solve this problem?

Thanks,
Maryam
0
Reply maryam 5/19/2010 10:30:26 AM

On May 19, 10:30=A0pm, "maryam " <maryam_tay...@yahoo.com> wrote:
> "Varun " <var3...@yahoo.co.in> wrote in message <ht0cut$8n...@fred.mathwo=
rks.com>...
> > "maryam " <maryam_tay...@yahoo.com> wrote in message <ht0c6g$jq...@fred=
..mathworks.com>...
> > > Hi dears,
> > > I am new member of mathgroups,my outputs in matlab are as complex num=
bers,I want to know how can I write them into an excel file. =A0
> > > Thanks
> > > Maryam
>
> > Hey,
>
> > store the complex numbers in a matrix and use the 'xlswrite' function.
>
> Dear Varun,
> Many thanks for your reply, I have already stored the data which are comp=
lex number in a matrix but xlswrite function writes the real unit in a exce=
l file only and discards the imaginary unit. What can I do to solve this pr=
oblem?
>
> Thanks,
> Maryam

I wasn't aware that Excel could handle complex numbers.
What version are you using?
0
Reply TideMan 5/19/2010 10:49:54 AM

"maryam " <maryam_tayefi@yahoo.com> wrote in message <ht0ek2$p0s$1@fred.mathworks.com>...
> "Varun " <var3161@yahoo.co.in> wrote in message <ht0cut$8n9$1@fred.mathworks.com>...
> > "maryam " <maryam_tayefi@yahoo.com> wrote in message <ht0c6g$jqe$1@fred.mathworks.com>...
> > > Hi dears,
> > > I am new member of mathgroups,my outputs in matlab are as complex numbers,I want to know how can I write them into an excel file.  
> > > Thanks
> > > Maryam
> > 
> > Hey,
> > 
> > store the complex numbers in a matrix and use the 'xlswrite' function.
> 
> Dear Varun,
> Many thanks for your reply, I have already stored the data which are complex number in a matrix but xlswrite function writes the real unit in a excel file only and discards the imaginary unit. What can I do to solve this problem?
> 
> Thanks,
> Maryam

Hey Maryam,

just convert all the complex numbers in the matrix to string using 'num2str' and then use 'xlswrite'. I think that should work.

Regards,
Varun
0
Reply Varun 5/19/2010 11:16:07 AM

"maryam " <maryam_tayefi@yahoo.com> wrote in message <ht0c6g$jqe$1@fred.mathworks.com>...
> Hi dears,
> I am new member of mathgroups,my outputs in matlab are as complex numbers,I want to know how can I write them into an excel file.  
> Thanks
> Maryam

Simplest solution:

put the complex numbers into  cell array, then use xlswrite.
0
Reply ade77 5/19/2010 3:47:04 PM

Hi maryam,

I have no idea on what your code is about, so maybe the following suggestion is not convenient to implement...

It's just an idea. How about creating for each of your complex numbers in Matlab separate matrices / arrays with its real and imaginary parts.

c = sqrt(-1)
c =

        0 + 1.0000i

rpart = real(c)

rpart =

     0
ipart = imag(c)

ipart =

     1

You may then write rpart and ipart into Excel by xlswrite. In Excel 2003 e.g. there is function =complex(real_num,i_num,suffix) that converts the two supplements into a complex number. From a practical point of view, I think this is cumbersome and you may need control over eventual complex numbers in your output. I would love to help you, but I am not strong enough in programming for that...

Good luck!
0
Reply tinne123 5/19/2010 5:26:04 PM

"maryam " <maryam_tayefi@yahoo.com> wrote in message <ht0c6g$jqe$1@fred.mathworks.com>...
> Hi dears,
> I am new member of mathgroups,my outputs in matlab are as complex numbers,I want to know how can I write them into an excel file.  
> Thanks
> Maryam

Hi, 

I had the same problem and there is a small piece of code for your help 

Considering Cnoise, as a 2-D complex matrix . then the complex data can be written to excel using the following code

%%%%%%%%%%%%%

a=strcat('=COMPLEX(',num2str(real(Cnoise(:))),',',num2str(imag(Cnoise(:))),')');
b=mat2cell(a,ones(1,size(a,1)),size(a,2));
d=(reshape(b,size(Cnoise,1),size(Cnoise,2)));
xlswrite('Noise.xlsx',d,1); %Write Attenuation

%%%%%%%%%%%%%

It worked for me, I hope this helps you too. 

Kind Regards
Dr. Saqib Ali
0
Reply saqib78 (1) 11/18/2011 6:14:29 PM

7 Replies
580 Views

(page loaded in 0.422 seconds)

Similiar Articles:













7/23/2012 7:44:11 PM


Reply: