From: Yuping Liang on
I have many matlab variables in a Matlab workspace, how do I save them into Excel?

E.g. I have list of variables, they are all 1D array with different length:

v1
v2
v3
......


I am looking for a simple command to save them and be able to load the saved file into Excel.

Thanks
yp
From: kinor on
"Yuping Liang" <yliang(a)satake-usa.com> wrote in message <hj1sil$cvg$1(a)fred.mathworks.com>...
> I have many matlab variables in a Matlab workspace, how do I save them into Excel?
>
> E.g. I have list of variables, they are all 1D array with different length:
>
> v1
> v2
> v3
> .....
>
>
> I am looking for a simple command to save them and be able to load the saved file into Excel.
>
> Thanks
> yp
Hi,
you could write a function which takes all your parameters by varargin and loop over them,
help inputname and
help xlswrite
shows you how to write each variable in a sheet called like the variable

help xlsread
help xlsfinfo
make you able to read it back


hth
kinor
From: Rick Rosson on
This is not an ideal solution, but it works.

1. Create a MATLAB function called "writevar.m" with the following code:

function writevar(x,k,filename)


col = char(64+k);

N = size(x,1);


Rg = sprintf([col '1:' col '%i' ],N);


xlswrite(filename,x,Rg);


end



2. Then, call your function from the command line or from a scipt, as
follows:

filename = 'myfile.xls';
writevar(v1,1,filename);
writevar(v2,2,filename);
writevar(v3,3,filename);


HTH.

Rick



"Yuping Liang" <yliang(a)satake-usa.com> wrote in message
news:hj1sil$cvg$1(a)fred.mathworks.com...
>I have many matlab variables in a Matlab workspace, how do I save them into
>Excel?
>
> E.g. I have list of variables, they are all 1D array with different
> length:
>
> v1
> v2
> v3
> .....
>
>
> I am looking for a simple command to save them and be able to load the
> saved file into Excel.
>
> Thanks
> yp