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 个评论

worker name has diffrent length and contain different number of word (not just first and last name)
xlsread create cell data. How can we search for item in cell array?

请先登录,再进行评论。

回答(2 个)

Walter Roberson
Walter Roberson 2011-3-3

0 个投票

See xlsread(), xlswrite() . With xlswrite() you can specify a particular cell range to write the data in to.
  1. xlsread to read both files into cell arrays.
  2. Use set operations (like, say, intersect) to find the names that are common to both.
  3. Use the corresponding indices to extract the jobs.
  4. 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

提问:

2011-3-3

Community Treasure Hunt

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

Start Hunting!

Translated by