get data from excel file
显示 更早的评论
I have two excel file. The first one is the main excel file that has two columns: one with all workers names and second column with their job. The second excel files has one column with some worker that has won a prize. I want a code that look at the main excel file and write a second column that has the jobs for those worker that won a price.
Note: if it is hard wo deal with xls file, I can move the information to txt file and work with txt file
回答(2 个)
Walter Roberson
2011-3-3
0 个投票
See xlsread(), xlswrite() . With xlswrite() you can specify a particular cell range to write the data in to.
Matt Tearle
2011-3-3
- xlsread to read both files into cell arrays.
- Use set operations (like, say, intersect) to find the names that are common to both.
- Use the corresponding indices to extract the jobs.
- Then use xlswrite to write the results.
Example of using intersect for this:
>> [names,idx] = intersect({'bob','sally','fred'},{'fred','sally'})
names =
'fred' 'sally'
idx =
3 2
类别
在 帮助中心 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!