MATLAB: How i plot this function

MATLABtwovariable

u(x,t)=t+sin(x-a*t)

Best Answer

One way, using the exact equation you posted:
syms x t
a = 4.2; % Use Appropriate Value
u(x,t) = t+sin(x-a*t);
figure
fsurf(u, [- pi pi 0 1])
and another possibility:
x = linspace( ... ); % Create Vector
t = linspace( ... ); % Create Vector
[X,T] = ndgrid(x,t);
u = @(x,t) t+sin(x-a.*t);
figure
mesh(X, T, u(X,T))
grid on
.