![](https://csdnimg.cn/release/download_crawler_static/87015910/bg4.jpg)
(完整 word 版)Matlab 在物理上的应用举例
w2=input(’w2=');
tf=10;
Ns=1000;t=linspace(0,tf,Ns);
dt=tf/(Ns-1); %分 Ns 个点,求出时间增量 dt
xplot=eval(x);yplot=eval(y); %计算 Ns 个点的位置 x(t),y(t)
figure(gcf);
subplot(1,2,1),
for i=1:750
plot(yplot(1:i),xplot(1:i)); %画点的轨迹图
axis('equal’); grid ; %使两轴比例相同
pause(0。01)
end
8.耦合振子
m1=2;m2=2;K1=16;K2=4; %???????
x0=[1;0];xd0=[6;6];tf=10; %????
M=[m1,0;0,m2];K=[K1+K2,—K2;—K2,K1+K2] ; %??????u(:,s)。
[u,L]=eig(K,M) ; %???????????
t=linspace(0,tf,101);x=zeros(2,101); %????????????
for s=1:2 %????????
alfa=sqrt(u(:,s)’*M*u(:,s)) ; %??????
u(:,s)= u(:,s)/alfa; %????????
w(j)=sqrt(L(j,j)); %?????????????
xt=u(:,j)*(u(:,j)'*M*x0*cos(w(j)*t)+u(:,j)'*M*xd0/w(j)*sin(w(j)*t));
x=x+xt; %???????
end
for r=1:2 %???x1,x1??
subplot(2,1,r)
plot(t。x(r,:)),grid;
xlabel(’xxx’);
ylabel([’yyy',num2str(r)]);
end
9.拍频
%%
t=0:0.001:10;
a1=input('??1=’);w1=input(’??1=’);
a2=input('??2=’);w2=input('??2=’);
y1=a1*sin(w1*t);
y2=a2*sin(w2*t);
y=y1+y2;
subplot(3,1,1),plot(t,y1),ylabel('y1')
subplot(3,1,2),plot(t,y2),ylabel(’y2’)
subplot(3,1,3),plot(t,y),ylabel(’y’),xlabel('t')
pause,sound(y1);pause(5),sound(y2);pause(5),sound(y),pause
subplot(1,1,1)
10。物块下滑
m1=input(’m1=');
评论0
最新资源