MATLAB Answers

How do you search a file for a matching string?

Asked by Vinay kumar Reddy on 2 Feb 2013

Hi,

I have a huge contacts list in a excel file which consists of following fields

FirstName LastName UserID EmailAddress.

I have FirstName and LastName in MATLAB as a variable.

How do I extract the user ID and EmailAddress for a corresponding FirstName and LastName?

Note:There are some 50,000 contacts in Excel file.

  0 Comments

Products

No products are associated with this question.

1 Answer

Answer by Azzi Abdelmalek
on 2 Feb 2013
 Accepted answer
[num,text,v]=xlsread('yourfile')
s1='firstname';
s2='lastname';
idx=find(strcmp(v(:,1),s1) & strcmp(v(:,2),s2)
Id=v(idx,3)
Email=v(idx,4)

  1 Comment


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today