Creating an anonymous function for ‘T’ is much easier and faster than using piecwise and the Symbolic Math Toolbox for this:
zeta0 = 0.5
L = 100;
W = 100;
h = 2;
g = 0.0098;
vt=sqrt(g*h);
c=1;
v=c*vt;
t1 = L/v;
t = t1;
T1 = @(x,y) zeta0*v*t/(2*L)*(1-cos(pi/50*x)).*(1-cos(pi/100*(y+150))) ;
T2 = @(x,y) zeta0*v*t/L*(1-cos(pi/50*x)) ;
T3 = @(x,y) zeta0*v*t/(2*L)*(1-cos(pi/50*x)).*(1-cos(pi/100*(y-150))) ;
T = @(x,y) ((0<=x) & (x<=100) & (-150<=y) & (y<=-50)).*T1(x,y) + ((0<=x) & (x<=100) & (-50<=y) & (y<=50)).*T2(x,y) + ((0<=x) & (x<=100) & (50<=y) & (y<=150)).*T3(x,y);
[X,Y] = ndgrid(-100:5:200);
figure
surf(X,Y,T(X,Y))
grid on
.
Best Answer