No BSD License  

Highlights from
VLOOKUP

3.0

3.0 | 3 ratings Rate this file 16 Downloads (last 30 days) File Size: 1.56 KB File ID: #12453

VLOOKUP

by Kardi Teknomo

 

29 Sep 2006 (Updated 29 Sep 2006)

vlookup tutorial

| Watch this File

File Information
Description

This is matrix version of VLOOKUP similar to MS Excel function.

Return matrix b which has equal size as m and the values are taken from
from the n column of lookup table lut. It will replace all NaN with zero.

example how to use:
Type this 2 matrix data

> m = [ 1 2 0; 3 4 1]
> lut = [0 0.5 12; 1 0.8 25; 2 0.4 32; 3 0.7 41]

produces
m = [ 1 2 0;
       3 4 1]
lut = [0 0.5 12;
       1 0.8 25;
       2 0.4 32;
       3 0.7 41]
> b=vlookup(m,lut,3)
   => [25 32 12;
       41 0 25]

> b=vlookup(m,lut,2)
   => [0.8 0.4 0.5;
       0.7 0 0.8]
 
Written by Kardi Teknomo http://people.revoledu.com/kardi/

Note: the code consist of three different versions of vlookup, the fastest is only consist of two lines code uncommented.

MATLAB release MATLAB 5.2 (R10)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
01 Oct 2006 KALAI KOVAN  
28 Feb 2007 Jeff H

This doesn't do what a vlookup does, at least the most commonly used (exact match) version. In your example, if I vlookup(1.5,lut,2) I should get back a NaN - 1.5 is not an element of lut(:,1). However your function would interpolate and yield 0.6. Dangerous!

10 Jul 2007 FATEN SOLTANI

comment pouvant savoir ? quelle couleur correspond une valeur de pixel

16 Mar 2008 ruchit chaturvedi

I agree with Jeff. Have to be very careful since the function does not give the exact match.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
matrices Kardi Teknomo 22 Oct 2008 08:41:51
lookup table Kardi Teknomo 22 Oct 2008 08:41:51
vlookup Kardi Teknomo 22 Oct 2008 08:41:51
lookup table Srinivas 03 Sep 2009 15:30:09

Contact us at files@mathworks.com