From: R P on
I want to fit a surface to my data. It is temperature (Z), given two factors: depth (X) and hour of the day (Y).

I've already made simulated data using SIN function (relating temperature to hour of the day) and EXP function (relating temperature to depth), and adding some random error.

How can I fit a surface to this data??

hour depth temperature
1 0 20.9
2 0 20.9
3 0 22.2
4 0 22.7
5 0 23.9
6 0 25.9
7 0 26.4
8 0 27.8
9 0 29.1
10 0 29.7
11 0 30.6
12 0 30.5
13 0 30.8
14 0 29.7
15 0 29.1
16 0 28.1
17 0 27.1
18 0 25.5
19 0 24
20 0 22.9
21 0 21.8
22 0 21.5
23 0 20.3
24 0 20.5
1 5 23
2 5 22.6
3 5 23.7
4 5 24.2
5 5 25
6 5 25.8
7 5 26.6
8 5 26.8
9 5 27.6
10 5 28.1
11 5 28.9
12 5 28.8
13 5 28
14 5 27.9
15 5 28.1
16 5 26.7
17 5 26.4
18 5 25.8
19 5 25
20 5 24.1
21 5 23.8
22 5 22.7
23 5 23
24 5 22.1
1 10 23.7
2 10 23.7
3 10 24.5
4 10 24.7
5 10 25
6 10 26
7 10 26
8 10 26
9 10 27.1
10 10 26.6
11 10 26.9
12 10 27.7
13 10 27
14 10 27.3
15 10 26.7
16 10 26.1
17 10 26.3
18 10 25.6
19 10 25.1
20 10 24.5
21 10 24.3
22 10 24
23 10 23.3
24 10 23.8
1 15 24.4
2 15 24.2
3 15 25
4 15 25.1
5 15 25.6
6 15 25
7 15 26.1
8 15 26.2
9 15 25.8
10 15 26.5
11 15 26.7
12 15 27
13 15 26.3
14 15 26.5
15 15 26.7
16 15 25.9
17 15 25.5
18 15 25.9
19 15 25.3
20 15 24.7
21 15 24.7
22 15 24.5
23 15 24.6
24 15 24

Thank you
From: John D'Errico on
"R P" <rpavao(a)colband.com.br> wrote in message <hskl6g$klt$1(a)fred.mathworks.com>...
> I want to fit a surface to my data. It is temperature (Z), given two factors: depth (X) and hour of the day (Y).
>
> I've already made simulated data using SIN function (relating temperature to hour of the day) and EXP function (relating temperature to depth), and adding some random error.
>
> How can I fit a surface to this data??
>
> hour depth temperature
> 1 0 20.9
....

No problem that I see.

[Tgrid,Hgrid,Dgrid] = gridfit(H,D,T,30,30,'smooth',5);
surf(Hgrid,Dgrid,Tgrid)
hold on
plot3(H,D,T,'o')

Find gridfit on the file exchange.

http://www.mathworks.com/matlabcentral/fileexchange/8998

HTH,
John