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

1 次查看(过去 30 天)
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.

采纳的回答

MathReallyWorks
MathReallyWorks 2017-5-22
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')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by