- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
如何求解参数依赖于时间或自变量的常微分方程组......初始值问题......?说出我的等式
Dy(1)/dt=a(t)*y(1)+b(t)*y(2);
Dy(2)/dt=-a(t)*y(3)+b(t)*y(1);
Dy(3)/dt=a(t)*y(2);
其中 a(t) 是向量,b(t) =c*a(t);其中 a 和 b 的值随时间变化,而不是单调的方式和每个时间步长。我尝试使用 this post 来解决这个问题....但是当我应用相同的原理时...我收到了错误消息
"Error using griddedInterpolant The point coordinates are not sequenced in strict monotonic order."
有人可以帮帮我吗?
最佳答案
请阅读到最后,看看答案的第一部分或第二部分是否与您相关:
第 1 部分:首先创建一个 .m
文件,其中包含描述您的计算的函数和将给出 a
和 b
的函数。例如:创建一个名为 fun_name.m
的文件,其中将包含以下代码:
function Dy = fun_name(t,y)
Dy=[ a(t)*y(1)+b(t)*y(2); ...
-a(t)*y(3)+b(t)*y(1); ...
a(t)*y(2)] ;
end
function fa=a(t);
fa=cos(t); % or place whatever you want to place for a(t)..
end
function fb=b(t);
fb=sin(t); % or place whatever you want to place for b(t)..
end
然后使用带有以下代码的第二个文件:
t_values=linspace(0,10,101); % the time vector you want to use, or use tspan type vector, [0 10]
initial_cond=[1 ; 0 ; 0];
[tv,Yv]=ode45('fun_name',t_values,initial_cond);
plot(tv,Yv(:,1),'+',tv,Yv(:,2),'x',tv,Yv(:,3),'o');
legend('y1','y2','y3');
当然,对于我写的 fun_name.m
案例,您不需要为 a(t)
和 b(t)
使用子函数,如果可能的话,您可以在 Dy
中使用显式函数形式(例如 cos(t)
等)。
第 2 部分: 如果 a(t)
和 b(t)
只是您碰巧拥有的无法表达的数字向量作为 t
的函数(如第 1 部分),那么您还需要有一个时间向量,它们中的每一个都会发生,这当然可以与您将用于ODE,但不需要,只要插值有效即可。当他们有不同的时间跨度或解决方案时,我将处理一般情况。然后您可以执行以下操作,创建 fun_name.m
文件:
function Dy = fun_name(t, y, at, a, bt, b)
a = interp1(at, a, t); % Interpolate the data set (at, a) at times t
b = interp1(at, b, t); % Interpolate the data set (bt, b) at times t
Dy=[ a*y(1)+b*y(2); ...
-a*y(3)+b*y(1); ...
a*y(2)] ;
为了使用它,请看下面的脚本:
%generate bogus `a` ad `b` function vectors with different time vectors `at` and `bt`
at= linspace(-1, 11, 74); % Generate t for a in a generic case where their time span and sampling can be different
bt= linspace(-3, 33, 122); % Generate t for b
a=rand(numel(at,1));
b=rand(numel(bt,1));
% or use those you have, but you also need to pass their time info...
t_values=linspace(0,10,101); % the time vector you want to use
initial_cond=[1 ; 0 ; 0];
[tv,Yv]= ode45(@(t,y) fun_name(t, y, at, a, bt, b), t_values, initial_cond); %
plot(tv,Yv(:,1),'+',tv,Yv(:,2),'x',tv,Yv(:,3),'o');
legend('y1','y2','y3');
关于matlab - 如何求解具有 transient 参数的常微分方程组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14343563/
我知道这个问题已经被问过很多次了,但我找不到适合我的答案。 我在 Spring Roo 应用程序中有两个实体,它们处于多对多关系、发布和组件中。 首先,我通过以下方式获取现有版本的实例 selecte
我正在尝试将用户详细信息存储到下表中:user、role、user_role。尝试保存详细信息时,它会引发以下错误。 Error during managed flush [org.hibernate
我有两个 hibernate 实体 Coupon 和 CouponHistory,在 CouponHistory 和 Coupon 之间具有单向关系。 @Entity @Table(name = "v
我在外键 dimension_id 之一的表中有表 product。所以在服务层编写我的测试用例时它显示了错误。 这是我的测试用例 @Transactional(propagation = Propa
在 ARM 架构手册中提到缓存可以是 transient 的和非 transient 的,并且它是由实现定义的。我无法理解关于缓存的 transient 内存的概念和使用。我正在尝试编写启用 MMU
我有 2 个域模型和一个 Spring REST Controller ,如下所示: @Entity public class Customer{ @Id private Long id; @OneT
我知道这个问题在Stackoverflow中有很多问题,但是即使有很多答案,这些答案也帮不了我什么,也没有找到答案。 在我的WebAPP中,它可以正常工作,但是当我将其转换为API时,它失败了(主题标
我有以下域名 class User { Boolean accountLocked String password Boolean passwordExpired Bo
我写了一个 elisp 宏,在 transient-mark-mode 中保留区域: (defmacro keep-region (command) "Wrap command in code t
这是我的员工类(class): @Entity public class Employee { @Id @GeneratedValue private int id; private String f
我正在通读 Windows Phone 7.5 Unleashed,有很多代码看起来像这样(在页面的代码隐藏中): bool loaded; protected override void OnNav
我有一个自连接员工实体类,其中包含与其自身相关的 id、name 和 ref 列。我想创建它的新实例并将其保存到数据库。 首先我创建了一个 Employee 类的实例并将其命名为 manager。然后
我有一个用于添加新公寓的表单,在该表单中我有一个下拉列表,用户可以在其中选择负责的人员。 显然,当您从下拉列表中选择并尝试保存公寓时,我的应用程序认为该人已被修改。它给了我下面的错误,指示我应该首先保
我正在尝试保存一个复杂的对象,该对象内部有许多引用元素,而且它在大多数情况下都能完美运行。 但是在某些情况下,我们会遇到以下异常, object references an unsaved trans
我遇到了一些可能的问题答案,但这是关于从 Hibernate 3.4.0GA 升级到 Hibernate 4.1.8 的问题。所以这曾经在以前的版本下工作,我已经四处搜索了为什么它在这个新版本中出现了
似乎一遍又一遍地问这个问题,我仍然找不到解决我问题的答案。我在下面有一个域模型。每个新创建或更新的“安全用户”都需要我确保其具有配置文件,如果没有,则创建一个新的配置文件并分配给它。 配置文件的要求相
我很难调试为什么 JPA 不级联我的 @ManyToMany 关系。我发现的所有答案都与缺少级联语句有关。但我确实拥有它们并且仍然得到: Caused by: org.hibernate.Transi
例如,当我使用 transient 通过更改 translate(x, y) 的值来实现 2s 持续时间的动画时。如何获取0.5s时刻translate(x, y)的当前值? 最佳答案 我认为你做不到
我在尝试保存属于多对多关联的对象时收到 TransientObjectException。我有点理解为什么会这样,但想了解如何正确完成我正在尝试做的事情。 简而言之,我正在尝试做的事情: 我的应用程序
transient final int 和 transient final Integer 有什么不同。 使用 int: transient final int a = 10; 序列化前: a = 1
我是一名优秀的程序员,十分优秀!