本帖最后由 牛小贱 于 2014-5-28 23:12 编辑
ChaChing 发表于 2013-9-6 00:06
求助完整格式:出错代码和出错提示!!!
??? Input argument "alfa" is undefined.
Error in ==> fcrack at 3
if -pi/2+alfa<=theta & theta<=pi/2-alfa
这是错误提示
我想将它调用到这个函数里面
- function dx=crackandliner(t,x,c,w)
- e=0.1;
- k=0.5;
- beta=0;
- phi0=0;
- alfa=pi/6;
- phi=atan(x(1)/x(3));
- theta=w*t+phi0+beta-phi;
- n=sin(w*t);
- m=cos(w*t);
- dx=zeros(4,1);
- dx(1)=x(2);
- dx(2)=e*w^2.*cos(w*t+phi0)-c*x(2)-x(1)+fcrack(theta)*k*m^2*x(1)...
- +fcrack(theta)*k*n*m*x(3);
- dx(3)=x(4);
- dx(4)=e*w^2.*sin(w*t+phi0)-c*x(4)-x(3)+fcrack(theta)*k*n^2*x(3)...
- +fcrack(theta)*k*n*m*x(1);
复制代码 主函数
- j=1;
- c=0.15;
- for w=0.1:0.01:3
- x0=[0.01;0.01;0.01;0.01];
- options=odeset;options.RelTol=1e-4;
- [t,x]=ode45(@crackandliner,[0 400],x0,options,c,w);
- p= sqrt((x(end-400:end,1).^2)+(x(end-400:end,3).^2));
- Pmax(j,1)=max(p);
- j=j+1;
- end
- w=0.1:0.01:3;
- h=plot(w,Pmax);
- title('p-w图');
- xlabel('回转速度w');
- ylabel('振幅p');
复制代码
|