MATLAB: What’s wrong with this script

matrices

t = linspace(0,2,100)
x = linspace(0,10,100)
U(t,x) = 10*sin(2*pi*(t-x/5))+2*sin(2*pi*(t+x/5))

Best Answer

You cannot use 0 or fractions in your indices into U.
The syntax you are using is not a function definition: the syntax is an array access.
Use
U = 10 * sin(2 * pi * (t-x/5)) + 2 * sin(2 * pi * (t+x/5));