我有2个微分方程,它们的B.C.相互关联。 我尝试使用以下代码解决它们:
syms v1(x) v2(x) L;
E = 1; %Modulous young
I = 1; %Moment of inertia
P = 1; %Force
Differintial_Equation1 = E*I*diff(v1,x,2) == -(sqrt(2)/2)*P*x;
Differintial_Equation2 = E*I*diff(v2,x,2) == -(sqrt(2)/2)*P*(L-x);
eqs = [Differintial_Equation1, Differintial_Equation2];
Dv1 = diff(v1,x); %v1'
Dv2 = diff(v2,x); %v2'
cond1 = [v1(0)==0, v1(L)+L*cos(pi/4) == v2(0)-L*cos(pi/4)]; %B.C
cond2 = [v2(L)==0, Dv1(L)+(pi/4) == Dv2(0)-(pi/4)]; %B.C 2
conds = [cond1, cond2];
vSol(x) = dsolve(eqs, conds);
我收到错误:
Error using sym/subsindex (line 766)
Invalid indexing or function definition. When defining a function, ensure
that the arguments are
symbolic variables and the body of the function is a SYM expression. When
indexing, the input must be
numeric, logical, or ':'.
Error in sol_2nd (line 29)
vSol(x) = dsolve(eqs, conds);
如果我删除Dv上的B.C并将其更改为v它工作正常,我在这里缺少什么?
提前致谢。
答案 0 :(得分:0)
在您的代码dsolve
中返回包含解决方案的结构。
您可以使用[v1sol(x) v2sol(x)]= dsolve(eqs, conds);
所以我们有这个:
syms v1(x) v2(x) L;
E = 1; %Modulous young
I = 1; %Moment of inertia
P = 1; %Force
Differintial_Equation1 = E*I*diff(v1,x,2) == -(sqrt(2)/2)*P*x;
Differintial_Equation2 = E*I*diff(v2,x,2) == -(sqrt(2)/2)*P*(L-x);
eqs = [Differintial_Equation1, Differintial_Equation2];
Dv1 = diff(v1,x); %v1'
Dv2 = diff(v2,x); %v2'
cond1 = [v1(0)==0, v1(L)+L*cos(pi/4) == v2(0)-L*cos(pi/4)]; %B.C
cond2 = [v2(L)==0, Dv1(L)+(pi/4) == Dv2(0)-(pi/4)]; %B.C 2
conds = [cond1, cond2];
[v1sol(x) v2sol(x)]= dsolve(eqs, conds);