Path: news.mathworks.com!not-for-mail
From: "Titus" <titus.edelhofer@mathworks.de>
Newsgroups: comp.soft-sys.matlab
Subject: Re: interp1 issue
Date: Thu, 13 Nov 2008 11:39:34 +0100
Organization: The MathWorks, Inc.
Lines: 32
Message-ID: <gfh057$fbt$1@fred.mathworks.com>
References: <gfghdh$405$1@fred.mathworks.com>
NNTP-Posting-Host: de-edelhoft-x.ac.mathworks.de
X-Trace: fred.mathworks.com 1226572775 15741 172.16.75.150 (13 Nov 2008 10:39:35 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 13 Nov 2008 10:39:35 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:500585



"Ning" <ning.robin@gmail.com> schrieb im Newsbeitrag 
news:gfghdh$405$1@fred.mathworks.com...
> For the example in matlab help 'interp1',
> t = 1900:10:1990;
> p = [75.995  91.972  105.711  123.203  131.669...
>     150.697  179.323  203.212  226.505  249.633];
> year=1975;
> interp1(t,p,year)
> 'ans =214.8585'
>
> What if the t is a 3-d matrix (2x3x10), p remains constant, and year is a 
> 2-d matrix (2x3), the answer would be a 2-d matrix (2x3) with various p 
> values. How to do this in matlab?


Hi,
as long as your data are not too large, I guess the simplest approach would 
be a loop here:

res = zeros(size(year));
for i=1:size(res,1)
  for j=1:size(res,2)
    res(i,j) = interp1(t(i,j,:), p, year(i,j));
  end
end

Although: interesting, the t changes but the values are the same? How come?

Titus