Excel Functions (analyzing data individually)
Ältere Kommentare anzeigen
Hey Guys,
Thanks for taking the time to review my question. I was wondering if it is possible to run the mean on an excel sheet whereby each row in the excel sheet would have its own individual answer.
For example, I have an excel file called Caregivers.xlsx and I would like to know the mean of the values in each individual row B:K separately. Meaning the mean of the values in B would give me a number, the mean of the values in C would give me a number, and D through K likewise. So far I have:
CaregiverData =xlsread ('Caregivers.xlsx','B2:B101'); CaregiverData1(1,1)=mean(CaregiverData);
CaregiverData =xlsread ('Caregivers.xlsx','C2:C101'); CaregiverData2(1,1)=mean(CaregiverData);
... same functions until I get to K
CaregiverData =xlsread ('Caregivers.xlsx','K2:K101'); CaregiverData3(1,1)=mean(CaregiverData);
Is there a way to compress this to a simple function?
Thanks
Salman
Antworten (2)
Kelly Kearney
am 12 Feb. 2015
Read all the data in, then take the average across dimension 2 (rows):
data = xlsread('Caregivers.xlsx', 1, 'B2:K101');
avg = mean(data,2);
And don't name your variables x1, x2, etc... you'll just give yourself headaches down the road. The array will allow you to access the mean of row N through avg(N).
1 Kommentar
Salman Salman
am 12 Feb. 2015
Guillaume
am 12 Feb. 2015
The second argument of mean tells you which dimension to average, thus:
CaregiverData = xlsread('Caregivers.xlsx', 'B2:K101'); %read all in one go
CaregiverMean = mean(CaregiverData, 2) %mean of each row
1 Kommentar
Salman Salman
am 12 Feb. 2015
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!