0
votes

I have coordinate vectors X and Y and corresponding vector of function values Z. I need to plot a surface Z(X,Y), and I need to put Z values on a regular mesh, right now X and Y define points distributed irregularly. What is the best way to do it in matlab?

Thanks!

2
use griddata to interpolate your data - obchardon

2 Answers

0
votes

If you have a function such as z=f(x,y) then you could use fsurf().

fsurf(@(x,y) x^2+y^2);

Or else, if you have data points then you could use surf()

[x, y]=meshgrid(-5:0.1:5);
z = x.^2 + y.^2;
mesh(x,y,z);

You could specify the axis as per your need.

0
votes

The following worked for me:

Zinter = scatteredInterpolant(Xs,Ys,Z) %defines interpolant for scattered data and allows to calculate values of z for any point