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: Reading from excel
Replies: 1   Last Post: Feb 16, 2013 3:53 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Derek Goring

Posts: 3,919
Registered: 12/7/04
Re: Reading from excel
Posted: Feb 16, 2013 3:53 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Saturday, February 16, 2013 6:16:16 PM UTC+13, Dhivakar wrote:
> Hi all,
>
> I have 2 columns of data (time, concentration) as input for my calculation. I have these data stored in an excel file in A and B columns. I have input data in sheets up to sheet25. I need to pick data from each sheet A and B column and calculate result and write the results in same sheet C column.
>
> My sheet names are 1,2,3,4.....25. Is there a way to write a command like this (example)
>
>
>
> for sheet=1:1:25
>
> [interval] = xlsread('waterevaporation','sheet','A:A');
>
> [flux] = xlsread('waterevaporation','sheet','B:B');
>
> l=size(interval)
>
> for i=1:1:l
>
> result(i,1) = interval(i,1)*flux(i,1)
>
> end
>
> q = xlswrite('waterevaporation',result,'sheet','C');
>
> end
>
>
>
> I get this error when i run the above code
>
>
>
> ??? Error using ==> xlsread>activate_sheet at 451
>
> Specified worksheet was not found.
>
>
>
> Error in ==> xlsread at 256
>
> activate_sheet(Excel,sheet);
>
>
>
> Error in ==> excelmultisheetopen_16_02_13 at 2
>
> [interval] = xlsread('waterevaporation','sheet','A:A');
>
>
>
> I kindly request you all to help me in this regard
>
>
>
> Thank you


No, you're getting sheets and columns mixed up.
a=xlsread('waterevaporation','sheet1'); % read all the data from sheet1
interval=a(:,1); % Extract interval
flux=a(:,2); % Extract flux
q=interval.*flux; % Calc flow, note .*
xlswrite('waterevaporation',q,'sheet1','c1') % export flow




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.