Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用微分方程和syms实现Matlab误差分析_Matlab - Fatal编程技术网

用微分方程和syms实现Matlab误差分析

用微分方程和syms实现Matlab误差分析,matlab,Matlab,我有两个微分方程,它们通过它们的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*(

我有两个微分方程,它们通过它们的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,它工作正常,我在这里缺少什么


提前感谢。

在您的代码中
dsolve
返回包含解决方案的结构

您可以使用
[v1sol(x)v2sol(x)]=dsolve(等式,条件)
因此,我们有:

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);

请您解释一下第29行中的sol_2nd是什么,您的代码不完整!请添加更多详细信息。第29行表示vSol(x)=dsolve(等式,条件);这是全部代码,前10行是注释。我确实运行了代码,但我的错误与您的不同!。。。我在sol_2nd(第29行)
中没有错误!您使用了syms v1(x)v2(x)L在第一行中。在最后一行中,您使用了
vSol(x)=dsolve(eqs,conds)为什么使用
vSol(x)
?这就是你犯错误的原因。vSol是结构类型,因此在运行代码后,您可以通过寻址结构元素来访问它。您是对的,它可以工作,谢谢:)