Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Writing to excel cells
Replies: 3   Last Post: Jan 31, 2013 12:47 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
dpb

Posts: 7,881
Registered: 6/7/07
Re: Writing to excel cells
Posted: Jan 31, 2013 10:09 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 1/31/2013 6:15 AM, Leyo Joseph wrote:
> I am looking for a method to write data to various cells of Excel sheet
> using a for loop.
> for example ==>
> data =[1 2 3 4 5];
> xlswrite('F:\Test Data\example.xlsx',menu,'data','a2');
> above writes contents of "data" to cell a2.
> Is there a way to wirite contents of data to various cells using a for
> loop.
> Like data(1) to cell(1,1) of excel.
> data(2) to cells(1,3)
> data(3) to cells(1,5)....


Use num2str() or sprintf() etc. create a dynamic cell address...

fn=fullfile('F:','Test Data', 'example.xlsx');
for i=1:length(data)
c=['a' num2str(2*i-1)];
xlswrite(fn,'data',c);
end

Obviously you can create more generic cell addresses by using character
variables for columns as well...

--





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.