如何用matlab画出平面波的传播,图的样子像下边的例子,求源程序,谢谢!

2024年12月03日 00:53
有1个网友回答
网友(1):

%平面波传播
clear                                  
m=3;   
x=(0:0.01:1)*m;
figure;grid on; hold on;        
axis([0,m,-1,1,-1,1])
data = zeros(size(x));
hy = stem(x,data,'r.');
hz = stem3(x,data,data,'b.');
n = length(x);
i=1;
view(3);
while 1
    if i>n
        data=[data(end),data(1:end-1)];
    else                      
        data=[sin(2*pi*x(i)),data(1:end-1)];
    end                               
    set(hy,'YData',data)                
    set(hz,'ZData',data)                
    drawnow                           
    pause(0.02)
    i=i+1;                            
end