Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.fr>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to find vector value via matrix value?
Date: Mon, 21 Jul 2008 20:04:02 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 17
Message-ID: <g62q3i$nrm$1@fred.mathworks.com>
References: <g62lhb$4sn$1@fred.mathworks.com> <g62nns$s4g$1@canopus.cc.umanitoba.ca>
Reply-To: "Bruno Luong" <b.luong@fogale.fr>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1216670642 24438 172.30.248.38 (21 Jul 2008 20:04:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 21 Jul 2008 20:04:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:480756



roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <g62nns$s4g$1@canopus.cc.umanitoba.ca>...
The easiest way to deal
> with this is likely:
> 
> m1 = m;
> m1(m1 < min(v(:))) = min(v);
> m1(m1 > max(v(:))) = max(v);
> interp1(v,v,m1,'nearest')
> -- 

This might be even easier:

v=unique(v); % precaustion
mn = interp1(v,v,m,'nearest','extrap')

% Bruno