Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: Reading from excel
Posted:
Feb 16, 2013 3:53 AM
|
|
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
|
|
|
|