Code covered by the BSD License  

Highlights from
vlookup - similar to MS Excel function

5.0

5.0 | 2 ratings Rate this file 25 Downloads (last 30 days) File Size: 1.57 KB File ID: #29233

vlookup - similar to MS Excel function

by

 

A matrix version of VLOOKUP similar to MS Excel function.

| Watch this File

File Information
Description

 VLOOKUP the function as vlookup in Excel
 
    [content, index] = vlookup(m, e, column, lookcolumn) look for 'e' in the 'lookcolumn'-th column of 'm', and return the coresponding 'column'-th element of 'm' in the same row.
 
the 'm' could be a numeric matrix of a cell matrix.

lookcolumn is 1 by default if omitted.

Example:

m = {1, 'a', [2 3];
2, 'b', 'cd'
3, 'a', true;};
 [content, index] = vlookup(m, 'a', 3, 2) then
content = {[2 3], 1};
index = [1;3]

  author: http://zhiqiang.org/blog/tag/matlab

MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
24 Nov 2013 Sergiy  
13 Jan 2011 Darin McCoy

BTW - you might want to consider making a change on line 33 of this from

index = find(strcmp(e, m(:, lookcolumn)));

to

index = find(strcmpi(e, m(:, lookcolumn)));

The second one finds things if they are not case sensitive

17 Nov 2010 Darin McCoy

This is really helpful!

Contact us