I want to plot z such that z(:,1)= [0;1]; but how do I implement that in this code
1 次查看(过去 30 天)
显示 更早的评论
close all;
dt = 0.1;%time step
u1=1;
u2=2;
c = u2-u1;
u = sign(u2-u1);
z=u*c;
k=0.12;
m=2.21;%initial parameters
v=1;
a=1.4;
tend=1000;
t=0;
i=1
while (t < tend-2*dt & i<t)
vh=v(i)-dt*k*z(1,i)/ (2*m);
z(2,i) = z(1,i)+ dt*vh;
%a(i+1)= -k*z(i)/2;
v(i+1)= vh-dt*k*z(2,i)/ (2*m);% + dt*a(i+1)/2;
i = i+1;
t = t + dt
end
plot(z);
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!