# 2D Fourier transform for surface fitting

25 views (last 30 days)

Show older comments

##### 0 Comments

### Answers (1)

Image Analyst
on 3 Sep 2021

##### 4 Comments

Image Analyst
on 4 Sep 2021

What's the function? Like sin(x) + cos(y) or something? Should be just a few lines of code if you use meshgrid to get a list of all (x,y) locations.

x1 = linspace(0, 5*pi, 400);

y1 = linspace(0, 3*pi, 300);

xPeriod = 2;

yPeriod = 2.4;

amplitude = 5;

[x, y] = meshgrid(x1, y1);

z = amplitude * (sin(2 * pi * x / xPeriod) + cos(2 * pi * y / yPeriod));

surf(x, y, z, 'Lines', 'none');

grid on;

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!