how plot function sine wave in two variable in MATLAB like y(x,t)=a* sin(wt-kx)

9 views (last 30 days)
i want to plot a model of travelling sin wave
y(x,t)=a* sin(ωt-kx)
at ω=2*π* λ* c ,k=2*π/ λ
t=linspace(0,50,100)
x=linspace(0,50,100)
and then need it to convert it in simulink

Answers (2)

Star Strider
Star Strider on 14 Aug 2023
Edited: Star Strider on 14 Aug 2023
Provide the appropriate constants, then perhaps this —
% y(x,t)=a* sin(ωt-kx)
% at ω=2*π* λ* c*t ,k=2*π/ λ
lambda = 6.5
lambda = 6.5000
k = 2*pi/lambda
k = 0.9666
a = 0.75
a = 0.7500
c = 299792458; % m/s
omega = 2*pi*lambda*c;
y = @(x,t) a*sin(omega*t-k*x)
y = function_handle with value:
@(x,t)a*sin(omega*t-k*x)
t=linspace(0,50,100);
x=linspace(0,50,100);
[T,X] = ndgrid(t, x);
figure
surf(X, T, y(X,T), 'EdgeColor','interp')
colormap(turbo)
xlabel('T')
ylabel('X')
zlabel('y(x,t)')
EDIT — (14 Aug 2023 at 01:22)
Code changed to reflect these updates in the original post:
y(x,t)=a* sin(ωt-kx)
at ω=2*π* λ* c ,k=2*π/ λ
EDIT — (14 Aug 2023 at 03:31)
Incorporated further amendments (changed from previous random values):
(a) is const assume =0.75 m and time period =6.5 sec
.

Walter Roberson
Walter Roberson on 14 Aug 2023
syms a c k lambda omega t x
Pi = sym(pi);
k = 2 * Pi / lambda
k = 
omega = 2 * Pi * lambda * c * t
omega = 
y(x, t) = a * sin(omega*t - k * x)
y(x, t) = 
symvar(y)
ans = 
You have provided ranges for x and t, but if we substitute those we end up with expressions in a c lambda. It is quite difficult to make sense of any plot in 5 independent dimensions.
  2 Comments
Rania
Rania on 14 Aug 2023
we can assume this is regural wave so the average amplitude (a) is const assume =0.75 m and time period =6.5 sec
Walter Roberson
Walter Roberson on 14 Aug 2023
That allows you to assign specific values for a but the time period does not give clear values for c or lambda . Is the time period 1/lambda so lambda = 1 / time period ? If so that would still not define c

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!