compare and calculate two excel sheet

3 views (last 30 days)
I have two excel sheet, one contains the social security no. and gender, the other one contains social security no. and each person's income, now I have to calculate the average income for each gender. I understand that I need to use the total income of each gender to divide the total number of them, as they are in two excel sheet, I m lost. Any one can help? thank you so much
  1 Comment
MathReallyWorks
MathReallyWorks on 21 May 2017
Hello Huitian Mao,
Please attach some similar excel sheet if you don't want to disclose the original one. It will be easy for us to solve your problem efficiently.

Sign in to comment.

Accepted Answer

MathReallyWorks
MathReallyWorks on 21 May 2017
Hello Huitian Mao,
I hope this will be helpful. I've attached a sample excel sheet of gender and income too. Change the location of excel sheets and run the code. It works as per your requirement.
%Assumptions:
%Both excel sheets have same number of rows
%1st coloum is social serial number and 2nd coloum is gender or income in
%both the sheets
clc;
[num,txt,raw] = xlsread('C:\Rahul\gender.xls');
[num1,txt1,raw1] = xlsread('C:\Rahul\income.xls');
num1=num1(:,2); %income
MaleIncome=0;
NumberOfMales=0;
MaleAvgIncome=0;
FemaleIncome=0;
NumberOfFemales=0;
FemaleAvgIncome=0;
for i=1:10
if char(txt(i))=='M'
MaleIncome=MaleIncome+num1(i);
NumberOfMales=NumberOfMales+1;
elseif char(txt(i))=='F'
FemaleIncome=FemaleIncome+num1(i);
NumberOfFemales=NumberOfFemales+1;
end
end
MaleAvgIncome=MaleIncome/NumberOfMales;
disp('Male average income : ')
disp(MaleAvgIncome);
FemaleAvgIncome=FemaleIncome/NumberOfFemales;
disp('Female average income : ')
disp(FemaleAvgIncome);

More Answers (1)

akshatha nayak
akshatha nayak on 25 Mar 2019
See mine filename is testdata1.xls it has 2 sheet 1st sheet has id name and branch I will enter id in gui and then i need to check whether that id is present in 1st sheet If it is present then store that id value along with current time in 2nd sheet
  1 Comment
akshatha nayak
akshatha nayak on 25 Mar 2019
I am doing eye recognition based attendance system project But i have a problem in capture and storing image and compare that inage with other images Can any 1 help me to solve this problem

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!