how plot function sine wave in two variable in MATLAB like y(x,t)=a* sin(wt-kx)
9 views (last 30 days)
Show older comments
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
0 Comments
Answers (2)
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
k = 2*pi/lambda
a = 0.75
c = 299792458; % m/s
omega = 2*pi*lambda*c;
y = @(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’
.
0 Comments
Walter Roberson
on 14 Aug 2023
syms a c k lambda omega t x
Pi = sym(pi);
k = 2 * Pi / lambda
omega = 2 * Pi * lambda * c * t
y(x, t) = a * sin(omega*t - k * x)
symvar(y)
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
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
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!