2

I have a set of data-points for the value of z depending on x and y. I am searching for some method in order to interpolate zi for the for xi, yi.

The problem is that x and y are not distributed in an orthogonal grid. Instead the grid-points x and y are distributed randomly.

Is there any MATLAB function for this available? (Ideally in standard MATLAB w/o specialized packages - e.g. statistic toolbox or others).

chappjc
  • 30,359
  • 6
  • 75
  • 132
BerndGit
  • 1,530
  • 3
  • 18
  • 47
  • 3
    How is it off-topic to ask a question about the availability of a built-in function within MATLAB to do something in MATLAB? This sounds very relevant, and the answer is reasonable (and possibly not obvious to average MATLAB users) and a useful thread for others to search. – txpaulm Dec 25 '15 at 03:24
  • 1
    Possible duplicate: https://stackoverflow.com/questions/21275574/scattered-data-interpolation/21277035 – knedlsepp Dec 26 '15 at 12:36
  • Off-topic?!?! What a joke! This is a duplicate, not off-topic. – chappjc Jan 13 '16 at 01:09
  • The question's mention of specialized packages is referring to the toolboxes that cost extra on top of core MATLAB. This is not asking for a recommendation for a tool/software/etc., it's asking for a relevant function to solve the problem. It has an answer, several actually. – chappjc Jan 13 '16 at 01:25
  • Yes chappjc, i have the feeling that people who voted to close this question are not aware of Mathworks pricing policy. Anyhow and most important i got a good answer. The closing of this question does not bother me. – BerndGit Jan 14 '16 at 20:34
  • @BerndGit I'm more bothered by the malfunction of the SO community that led to the decision. Only 1 of the 5 who voted to close as off-topic have any real [tag:matlab] standing. But also, it is beneficial to the broader MATLAB community ("the internet") to have this post linked to the other. That cannot be done while it is erroneously closed. – chappjc Jan 14 '16 at 23:31

3 Answers3

1

It sounds like you are after griddata. Assuming xi and yi follow a meshgrid/ndgrid rules, then:

zi = griddata(x,y,z,xi,yi);

Should do the trick for you.

Shai
  • 111,146
  • 38
  • 238
  • 371
0

I just had a thought, you mentioned 'random'... if you don't mean interpolation, and you actually mean fitting, there's a nice tool available called gridfit, which estimates values permitting noise in the measurements:

[zgrid,xgrid,ygrid] = gridfit(x,y,z,xnodes,ynodes,varargin)

http://uk.mathworks.com/matlabcentral/fileexchange/8998-surface-fitting-using-gridfit

Sanjay Manohar
  • 6,920
  • 3
  • 35
  • 58
-1

interp2 does just that:

Zq = interp2(X,Y,Z,Xq,Yq)

where you put the points you want to query in Xq Yq.

Sanjay Manohar
  • 6,920
  • 3
  • 35
  • 58
  • 1
    Thanks for your comment. I am afraid this won't work since afaik for interp2 the value of X and Y have to follow a meshgrid() distribution. In my question X and Y are not on an ortogonal matrix. – BerndGit Dec 24 '15 at 13:30