用ode45解方程出现的问题
总是出现一下的错误提示??? Inputs to superiorfloat must be floats, namely single or double.
Error in ==> funfun\private\odearguments at 135
dataType = superiorfloat(t0,y0,f0);
Error in ==> ode45 at 171
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, ...
Error in ==> lag at 5
=ode45(@lagelangri,,y0)
我的求解代码是
function lag
q0=load('zuobiao.txt');
vq0=load('sudu.txt');
y0=
=ode45(@lagelangri,,y0)
请问应该怎么修改呀?
拜谢啦!!
求教:ode45解方程
function f=lagelangri(t,q)syms t
load yizhijiao.mat; L=load('ganchang.txt'); F=load('waijiali.txt'); m=load('zhiliang.txt');
w=load('lifangxiangjiao.txt'); Mc=load('liju.txt'); n=length(L);
o=length(U);%U为独立坐标变量%
for i=1:n
Fx(i)=F(i)*cos(w(i)); Fy(i)=F(i)*sin(w(i));
Fa(3*i-2)=Fx(i); Fa(3*i-1)=Fy(i); Fa(3*i)=Mc(i);
end
syms a b c d e f g h k
q=;
MK(1)=q(1)-1/2*L(1)*cos(q(2*n+1)); MK(2)=q(n+1)-1/2*L(1)*sin(q(2*n+1));
for i=2:n
MK(2*i-1)=q(i)-1/2*L(i)*cos(q(2*n+i))-q(i-1)-1/2*L(i-1)*cos(q(2*n+i-1));
MK(2*i)=q(n+i)-1/2*L(i)*sin(q(2*n+i))-q(n+i-1)-1/2*L(i-1)*sin(q(2*n+i-1));
end
MK(2*n+1)=40-q(n)-1/2*L(n)*cos(q(3*n)); MK(2*n+2)=10-q(2*n)-1/2*L(n)*sin(q(3*n));
M=; Mq=jacobian(M,q); Mt=diff(M,t)
for i=1:3*n, Kq(:,i)=diff(Mq(:,i),q(i)); end
Mtt=diff(M,t,2); Kt=diff(Mq,t);
q0=load('zuobiao.txt'); vq=load('sudu.txt')
r=-Kq*(vq.*vq)-2*Kt*vq-Mtt; F=;
for i=1:n
J(i)=1/12*m(i)*L(i)^2; z(3*i-2)=m(i); z(3*i-1)=m(i); z(3*i)=J(i);
end
Z=diag(z); N=length(F)-length(z); MZ=; AK=MZ\F;
x1=AK(1:3*n); x2=AK(3*n+1:end); f=
function lag
q0=load('zuobiao.txt'); vq0=load('sudu.txt'); y0=
=ode45(@lagelangri,,y0)
出错信息:
??? Inputs to superiorfloat must be floats, namely single or double.
Error in ==> funfun\private\odearguments at 135
dataType = superiorfloat(t0,y0,f0);
Error in ==> ode45 at 171
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, ...
Error in ==> lag at 5
=ode45(@lagelangri,,y0)
求各位大侠指点一二。谢谢啦!!
[ 本帖最后由 ChaChing 于 2009-5-2 11:04 编辑 ]
求助:ode45解方程
我要求解的微分方程方程是类似这样的q=
x2=2*cos(a)-sin(c)+cos(b)*sin(g)-k
当然是有九个未知数,有九个方程了,形式都差不多。我想用ode45来解,可是想ode45只能解类似这样的X2=2*cos(q(1))-sin(q(3))+cos(q(2))*sin(q(6))-q(9)形式的方程。请问可以怎么办啊?有什么方式可以把x2的形式换成X2的形式吗?或有其他的什么方法可以解决这个问题吗?拜谢各位大侠了!!
ode45解微分方程的问题(需要ode45解方程的也可看看,有帮助的)
现在已经知道下面这个是可以算出结果的function shuzhijie
y0=;
=ode45(@shuzhi,,y0)
function F=shuzhi(t,y)
a=y(1);b=y(2);c=y(3);d=y(4);e=y(5);f=y(6);
f=;
F=;
可是下面这个和上面的差不多,但是为什么得不出结果呢?
function shuzhijie02
q0=;
=ode45(@mmmm,,q0)
function F=mmmm(t,q)
a=q(1);b=q(2);c=q(3);d=q(4);e=q(5);f=q(6);g=q(7);h=q(8);k=q(9);
%syms a b c d e f g h k
load fangcheng
F=
其中 load fangcheng后可得
H =
2432*cos(h)^2*sin(g)^2*cos(k)^2+480000*cos(h)^2*sin(k)^2-60000*sin(g)*cos(g)*cos(k)*sin(k))
2432*cos(h)^2*sin(g)^2*cos(k)^2+480000*cos(h)^2*sin(k)^2-60000*sin(g)*cos(g)*cos(k)*sin(k))
2432*cos(h)^2*sin(g)^2*cos(k)^2+480000*cos(h)^2*sin(k)^2-60000*sin(g)*cos(g)*cos(k)*sin(k))
2432*cos(h)^2*sin(g)^2*cos(k)^2+480000*cos(h)^2*sin(k)^2-60000*sin(g)*cos(g)*cos(k)*sin(k))
2432*cos(h)^2*sin(g)^2*cos(k)^2+480000*cos(h)^2*sin(k)^2-60000*sin(g)*cos(g)*cos(k)*sin(k))
2432*cos(h)^2*sin(g)^2*cos(k)^2+480000*cos(h)^2*sin(k)^2-60000*sin(g)*cos(g)*cos(k)*sin(k))
2432*cos(h)^2*sin(g)^2*cos(k)^2+480000*cos(h)^2*sin(k)^2-60000*sin(g)*cos(g)*cos(k)*sin(k))
2432*cos(h)^2*sin(g)^2*cos(k)^2+480000*cos(h)^2*sin(k)^2-60000*sin(g)*cos(g)*cos(k)*sin(k))
2432*cos(h)^2*sin(g)^2*cos(k)^2+480000*cos(h)^2*sin(k)^2-60000*sin(g)*cos(g)*cos(k)*sin(k))
出错信息是:
??? Inputs to superiorfloat must be floats, namely single or double.
Error in ==> funfun\private\odearguments at 135
dataType = superiorfloat(t0,y0,f0);
Error in ==> ode45 at 171
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, ...
Error in ==> shuzhijie02 at 4
=ode45(@mmmm,,q0)
由于方程H比较长,是由前面算出来的,一共是九个方程,写不下,所以我只是在每个方程的后面抽取了一段写在这里了。方程H是没多大关系的,是由前面计算出来的。还请那位大侠帮忙看看,为什么下面这个和上面的那个差不多,但下面的算不出结果,上面的却能出结果呢?还请各位大侠给点指点,小弟感激不尽啦!!
页:
[1]