24小时热门版块排行榜    

Znn3bq.jpeg
查看: 1565  |  回复: 3

木木鱼的雨

新虫 (初入文坛)

[求助] matlab用ode45求解二阶微分方程为题 已有2人参与

function  dq=z_t_equation(t,q,flag,n)
switch flag
    case ''
syms x Fn Ff
B=0.4e-3;
a=11.932;
EI=343;
v=0.3;
l=0.15;
m0=0.025;
ra=3.276;
c=29.8;
cof=0.33;
d=0.15e-3;
omg=2*pi*n./60;
gama=pi/6;
Fa0=100;
kn=1.4e7;
kd=(2*kn.*(1-v))./(2-v);

                 %以上为常数参量
omt=sqrt(EI./(ra.*l.^4));
bt=omg./omt;
et=l.^3./EI;
eb=m0./(ra.*l);
ebb=c./(ra.*omt);
tao=omg.*t;
dba=d./l;
Bba=B./l;
                    %以上为无量纲化常量                  
f=sin((a*x)-sinh(a*x)-((sin(a)+sinh(a)).*(cos(a*x)-cosh(a*x)))/(cos(a)+cosh(a)));%形函数
f11=sin((a)-sinh(a)-((sin(a)+sinh(a)).*(cos(a)-cosh(a)))/(cos(a)+cosh(a)));
df1=diff(f,1);
df2=diff(f,2);
df4=diff(f,4);
f1=f.*f;
f2=f.*df4;
f3=-x.*f.*df1;
f4=f.*df2.*(1-x.^2);
f5=f.*df2;
F0=matlabFunction(f);
F1=matlabFunction(f1);
F2=matlabFunction(f2);
F3=matlabFunction(f3);
F4=matlabFunction(f4);
F5=matlabFunction(f5);
A1=integral(F3,0,1);
A2=integral(F4,0,1);
A3=integral(F5,0,1);
A4=et.*integral(F0,0,1);
A5=et.*f11;
cta1=acos((kd.*B.*tan(gama)+2*cof.*kn.*d)./(kd.*B.*tan(gama)+2*cof.*kn.*B));
cta2=acos(d/B);
cta3=acos((-d.*kd.*tan(gama)+cof.*d.*kn)./(B.*kd.*tan(gama)-cof.*B.*kn));
M=bt.^2.*integral(F1,0,1);
C=ebb.*bt.*integral(F1,0,1);
K=integral(F2,0,1);

(-inf<q(1))&(q(1)<inf);
if q(1)>dba/f11;
    Fn=kn.*l.*(f11.*q(1)-dba).*cos(gama);
elseif q(1)<-dba/f11;
     Fn=kn.*l.*(f11.*q(1)+dba).*cos(gama);
else q(1)>=-dba/f11&&q(1)<=dba/f11;
     Fn=0;
end
if q(1)<Bba/f11&&q(1)>=Bba.*cos(cta1)/f11&&q(2)<0;
    Ff=kd.*l.*sin(gama).*(f11.*q(1)-Bba)+cof.*kn.*l.*(f11.*q(1)-dba).*cos(gama);
elseif q(1)<Bba.*cos(cta1)/f11&&q(1)>=Bba.*cos(cta2)/f11&&q(2)<0;
    Ff=-cof.*kn.*l.*(f11.*q(1)-dba).*cos(gama);
elseif q(1)<Bba.*cos(cta2)/f11&&q(1)>=-Bba.*cos(cta2)/f11;
    Ff=0;
elseif q(1)<-Bba.*cos(cta2)/f11&&q(1)>=Bba.*cos(cta3)/f11&&q(2)<0;
    Ff=kd.*l.*sin(gama).*(-f11.*q(1)-dba);
elseif q(1)<Bba.*cos(cta3)/f11&&q(1)>=-Bba/f11&&q(2)<0;
    Ff=-cof.*kn.*l.*cos(gama).*(f11.*q(1)+dba);
elseif q(1)<-Bba.*cos(cta1)/f11&&q(1)>-Bba/f11&&q(2)>0;
    Ff=kd.*l.*sin(gama).*(f11.*q(1)-Bba)-cof.*kn.*l.*(f11.*q(1)+dba).*cos(gama);
elseif  q(1)<-Bba.*cos(cta2)/f11&&q(1)>=-Bba.*cos(cta1)/f11&&q(2)>0;
     Ff=cof.*kn.*l.*(f11.*q(1)+dba).*cos(gama);
elseif  q(1)<-Bba.*cos(cta3)/f11&&q(1)>=Bba.*cos(cta2)/f11&&q(2)>0;
     Ff=kd.*l.*sin(gama).*(f11.*q(1)-dba);
elseif  q(1)<=Bba/f11&&q(1)>=-Bba.*cos(cta3)/f11&&q(2)>0;
     Ff=cof.*kn.*l.*(f11.*q(1)-dba).*cos(gama);
end                                                                                                
   %以上为函数参量的定义
F=A1.*bt.^2.*q(1)+bt.^2.*A2.*q(1)./2+eb.*bt.^2.*A3.*q(1)+A4.*Fa0.*sin(3*tao)-A5.*(Fn.*cos(gama)+Ff.*sin(gama));
dq(1)=q(2);
dq(2)=(F-C.*q(2)-K.*q(1))./M;
q=[q(1);q(2)];
dq=[dq(1);dq(2)];
         otherwise
        error(['error']);
end

运行出错,显示
从 sym 转换为 double 时出现以下错误:
DOUBLE cannot convert the input expression into a double array.
我是初学者,还望懂的人帮我调试一下,不胜感激!
回复此楼

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

木木鱼的雨

新虫 (初入文坛)

这是求解命令部分
clc
h=[0,30];
z0=[0;0];
n=6000;
[t,q]=ode45('z_t_equation',h,z0,[],n);
plot(t,q)
[t,q]
2楼2016-08-31 22:35:02
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

FMStation

至尊木虫 (知名作家)

【答案】应助回帖

感谢参与,应助指数 +1
https://www.mathworks.com/matlab ... /view_thread/302893
DOUBLE cannot convert the input expression into a double array

I would suggest putting in a disp(F_h); just before that line and seeing what
result you are getting.
3楼2016-09-01 06:26:07
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

chendequan

铁虫 (小有名气)

【答案】应助回帖

感谢参与,应助指数 +1
内容已删除
QQ:516477448,真心帮助解决MATLAB相关问题,提供详细资料,Word文档明确具体问题及要求,尽力而为!
4楼2016-09-01 09:17:09
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 木木鱼的雨 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 急需调剂 +7 绝不放弃22 2026-04-15 8/400 2026-04-17 23:54 by 绝不放弃22
[考研] 化工学硕294分,求导师收留 +33 yzyzx 2026-04-12 37/1850 2026-04-17 23:00 by wunaiy88
[考研] 一志愿华中农业071010,320求调剂 +17 困困困困坤坤 2026-04-14 19/950 2026-04-17 20:08 by 关一盏灯cd
[教师之家] 山东双非院校考核超级无底线,领导幸灾乐祸,教师遭殃恐 +4 qut2026 2026-04-11 8/400 2026-04-17 16:10 by 会飞的猪157
[考研] 322求调剂 +6 tekuzu 2026-04-17 6/300 2026-04-17 13:48 by Espannnnnol
[考研] 335求调剂 +20 想上岸呀!! 2026-04-12 23/1150 2026-04-17 10:50 by cuisz
[考研] 294求调剂 +14 淡然654321 2026-04-15 14/700 2026-04-16 21:01 by lpl364211
[考研] 通信工程求调剂!!! +6 zlb770521 2026-04-14 6/300 2026-04-15 20:00 by 学员JpLReM
[考研] 生物学调剂 +9 纸扇zhishan 2026-04-13 9/450 2026-04-15 18:28 by AN流800
[考研] 297工科调剂? +14 河南农业大学-能 2026-04-13 15/750 2026-04-15 13:25 by 黑科技矿业
[考研] 271求调剂 +35 2261744733 2026-04-11 41/2050 2026-04-14 15:36 by zs92450
[考研] 245求调剂 +6 冰糖橘?汽水 2026-04-13 10/500 2026-04-14 10:49 by jyl0317
[考研] 300分求调剂 (085501机械专硕,本科扬大) +9 xu@841019 2026-04-11 10/500 2026-04-14 08:48 by 木木mumu~
[考研] 290求调剂 +18 柯淮然 2026-04-12 20/1000 2026-04-13 12:56 by cyh—315
[考研] 0831一轮调剂失败求助 +10 小熊睿睿_s 2026-04-11 10/500 2026-04-12 22:43 by 长弓傲
[考研] 一志愿浙大生物325分求调剂 +9 zysheng 2026-04-12 9/450 2026-04-12 22:31 by yuyin1233
[考研] 339求调剂 +8 hanwudada 2026-04-11 9/450 2026-04-12 15:36 by laoshidan
[考研] 调剂求助 +6 果然有我 2026-04-11 7/350 2026-04-11 16:22 by 明月此时有
[考研] 调剂 +5 文道星台 2026-04-11 5/250 2026-04-11 15:01 by 凯凯要变帅
[考研] 求调剂 +3 胃痉挛累了 2026-04-11 5/250 2026-04-11 14:13 by luhong1990
信息提示
请填处理意见