matlab - 3d plot of wave function -


how can plot wave function n=a*cos(k*x-w*t) in matlab in 3d simulation? code used was:

k=0.05; f=100; w=2*pi*f; a=1; x=[-5:1:5]; t=[0:2:20]; n=a.*cos(k.*x-w.*t); surf(x,t,n); 

to plot surface need mesh of data. x,t created line, there single t every x, surface has multiple t every x.

if change definition of x , t to:

[x,t]=meshgrid(-5:1:5,0:2:20); 

your code runs , plots:

enter image description here


Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -