matlab如何将脚本文件改成函数文件,下面是我的程序.u=zeros(1,2511);for t=1:1:11u(t)=0.05*t;endfor t=12:2510;k1=0.01*u(t-1)*(1-0.1*u(t-1))+0.01*u(t-10);k2=0.01*(u(t-1)+0.5*k1)*(1-0.1*(u(t-1)+0.5*k1))+0.01*(u(t-10)+0.5*k1);k3=0.01*(u(t
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/28 19:09:02
matlab如何将脚本文件改成函数文件,下面是我的程序.u=zeros(1,2511);for t=1:1:11u(t)=0.05*t;endfor t=12:2510;k1=0.01*u(t-1)*(1-0.1*u(t-1))+0.01*u(t-10);k2=0.01*(u(t-1)+0.5*k1)*(1-0.1*(u(t-1)+0.5*k1))+0.01*(u(t-10)+0.5*k1);k3=0.01*(u(t
matlab如何将脚本文件改成函数文件,下面是我的程序.
u=zeros(1,2511);
for t=1:1:11
u(t)=0.05*t;
end
for t=12:2510;
k1=0.01*u(t-1)*(1-0.1*u(t-1))+0.01*u(t-10);
k2=0.01*(u(t-1)+0.5*k1)*(1-0.1*(u(t-1)+0.5*k1))+0.01*(u(t-10)+0.5*k1);
k3=0.01*(u(t-1)+0.5*k2)*(1-0.1*(u(t-1)+0.5*k2))+0.01*(u(t-10)+0.5*k2);
k4=0.01*(u(t-1)+k3)*(1-0.1*(u(t-1)+k3))+0.01*(u(t-10)+0.5*k3);
u(t)=u(t-1)+(k1+2*k2+2*k3+k4)/6;
for k=1:1:5
if t==500*k+10
u(t)=(0.5^(2*k))*u(t-1);
end
end
end
t=0:2510;
plot(t,u);
matlab如何将脚本文件改成函数文件,下面是我的程序.u=zeros(1,2511);for t=1:1:11u(t)=0.05*t;endfor t=12:2510;k1=0.01*u(t-1)*(1-0.1*u(t-1))+0.01*u(t-10);k2=0.01*(u(t-1)+0.5*k1)*(1-0.1*(u(t-1)+0.5*k1))+0.01*(u(t-10)+0.5*k1);k3=0.01*(u(t
function Untitled2( )
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
u=zeros(1,2511);
for t=1:1:11
u(t)=0.05*t;
end
for t=12:2510;
k1=0.01*u(t-1)*(1-0.1*u(t-1))+0.01*u(t-10);
k2=0.01*(u(t-1)+0.5*k1)*(1-0.1*(u(t-1)+0.5*k1))+0.01*(u(t-10)+0.5*k1);
k3=0.01*(u(t-1)+0.5*k2)*(1-0.1*(u(t-1)+0.5*k2))+0.01*(u(t-10)+0.5*k2);
k4=0.01*(u(t-1)+k3)*(1-0.1*(u(t-1)+k3))+0.01*(u(t-10)+0.5*k3);
u(t)=u(t-1)+(k1+2*k2+2*k3+k4)/6;
for k=1:1:5
if t==500*k+10
u(t)=(0.5^(2*k))*u(t-1);
end
end
end
t=0:2510;
plot(t,u);
end
保存名为函数名.