看看我的MATLAB程序哪里出错了?程序如下:function yp=zhendong(t,y)global b w w1 h;yp=[y(2);-2*b*y(2)-w~2*y(1)+h*cos(w1*t);clear allglobal b w w1 h;h=0.4;A=0.2;w=0.3*pi;k=[0.1:0.01:2];w10=k*w;b1=[0.1:0.1:0.4];tspan=[0 100];y0=[A;0];optio

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 00:14:20

看看我的MATLAB程序哪里出错了?程序如下:function yp=zhendong(t,y)global b w w1 h;yp=[y(2);-2*b*y(2)-w~2*y(1)+h*cos(w1*t);clear allglobal b w w1 h;h=0.4;A=0.2;w=0.3*pi;k=[0.1:0.01:2];w10=k*w;b1=[0.1:0.1:0.4];tspan=[0 100];y0=[A;0];optio
看看我的MATLAB程序哪里出错了?
程序如下:
function yp=zhendong(t,y)
global b w w1 h;
yp=[y(2);-2*b*y(2)-w~2*y(1)+h*cos(w1*t);
clear all
global b w w1 h;
h=0.4;A=0.2;w=0.3*pi;k=[0.1:0.01:2];
w10=k*w;
b1=[0.1:0.1:0.4];tspan=[0 100];y0=[A;0];
options=odeset('Reltol',1e-6,'Abstol',1e-6);
for nb1=1:length(b1)
b=b1(nb1);
for nw1=1:length(w10)
w1=w10(nw1);
[t,y]=ode45('zhendong',tspan,y0,options);
A(nb1,nw1)=max(y(:,1));
end
end
subplot(2,1,1);plot(t,y(:,1));
subplot(2,1,2);plot(k,A);
错误如下:
function yp=zhendong(t,y)
|
Error:Function definitions are not permitted at the prompt or in scripts.

看看我的MATLAB程序哪里出错了?程序如下:function yp=zhendong(t,y)global b w w1 h;yp=[y(2);-2*b*y(2)-w~2*y(1)+h*cos(w1*t);clear allglobal b w w1 h;h=0.4;A=0.2;w=0.3*pi;k=[0.1:0.01:2];w10=k*w;b1=[0.1:0.1:0.4];tspan=[0 100];y0=[A;0];optio
matlab函数不能在命令窗口进行定义,需要重新建立M文件来定义函数.