Effacer les filtres
Effacer les filtres

How can I delete a row in a excel dokument if the value in a colonm is = F???

1 vue (au cours des 30 derniers jours)
I have an assignment In Matlab, and I am not a very experience user of it, so I would love if any1 og you could help me out.
this is part of my assignment and I only need help top the question D
I have two excel dokument one with Social Security numbers in column 1. and income in column 2. the other dokument I have SSN I column 1. and gender in colonm 2 (F or M) for the gender. I really hope some of you guys can help me out.

Réponse acceptée

MathReallyWorks
MathReallyWorks le 22 Mai 2017
Hello Peter Johansen,
Here you go. Use this code. It deletes all the F rows and the corresponding rows in income excel sheet too. It saves the final excel sheets as genderlistfinal.xls and incomelistfinal.xls in current folder. Check it out.
[num,txt,raw] = xlsread('gender.xls');
[num1,txt1,raw1] = xlsread('income.xls');
num1=num1(:,2); %income
j=1;
for i=1:10
if char(txt(i))=='M'
num2(j)=num1(i);
txt2(j)=txt(i);
j=j+1;
end
end
filename1 = 'genderlistfinal.xls';
xlswrite(filename1,txt2')
filename2 = 'incomelistfinal.xls';
xlswrite(filename2,num2')

Plus de réponses (0)

Catégories

En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by