matlab中dde23函数_时滞模型的matlab编程

matlab中dde23函数_时滞模型的matlab编程ddex1histz=@(t)2*ones(2,1);ddex1dez=@(t,y,Z)[y(1)*(1+0.1*sin(t)-0.1*Z(1,1)-y(2)/(1+y(1)));    y(2)*((2+sin(t))*10^(-5)+9*Z(1,2)/(1+Z(1,2))-Z(2,1))]; sol=dde23(ddex1dez

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

matlab中dde23函数_时滞模型的matlab编程延迟微分方程

matlab提供了dde23求解非中性微分方程。dde23的调用格式如下:
sol = dde23(ddefun,lags,history,tspan)
lags是延迟量,比如方程中包含y1(t-0.2)和y2(t-0.3)则可以使用lags=[0.2,0.3]。
这里的ddefun必须采用如下的定义方式:
dydt = ddefun(t,y,Z)
其中的Z(:,1)就是y(t-lags(1)),Z(:,2)就是y(t-lags(2))…
下面是使用dde23求解延迟微分方程的两个例子。

第一个例子:

matlab中dde23函数_时滞模型的matlab编程

代码如下:

ddex1dez = @(t,y,Z) [y(1)*(1 + 0.1*sin(t)-0.1*Z(1,1) – y(2)/(1+y(1)) );
    y(2)*( (2+sin(t))*10^(-5) + 9*Z(1,2)/(1+Z(1,2)) – Z(2,1) )];

 %y(1)表示x_1(t),因为dde求解的结果中sol会有个x,为了区别用y(1)表示x_1(t)Z(1,1)表示时滞项x_1(t-0.1);Z(1,2)表示时滞项x_1(t-0.3)

sol = dde23(ddex1dez,[0.1, 0.3],[2 2],[0, 50]);%dde23(@….,tau,history,tspan);

 %[0.1, 0.3]是时滞,[2 2]是初值,[0, 50]是时间范围

figure;
% plot(sol.x,sol.y)
plot(sol.x,sol.y(1,:) )
hold on
plot(sol.x,sol.y(2,:),’-.’ )
hold off

title(‘时滞微分方程组’);
xlabel(‘time t’);
ylabel(‘solution y’);
legend(‘x1′,’x2’);

matlab中dde23函数_时滞模型的matlab编程

第二个例子:

This example shows how to use dde23 to solve a system of DDEs with constant delays.

The differential equations are:

matlab中dde23函数_时滞模型的matlab编程

are solved on [0,5] with history:

matlab中dde23函数_时滞模型的matlab编程

for t ≤ 0.

  1. Create a new program file in the editor. This file will contain a main function and two local functions.

  2. Define the first-order DDE as a local function.

    function dydt = ddex1de(t,y,Z) ylag1 = Z(:,1); ylag2 = Z(:,2); dydt = [ylag1(1); ylag1(1)+ylag2(2); y(2)]; end
  3. Define the solution history as a local function.

    function S = ddex1hist(t) S = ones(3,1); end
  4. Define the delays, τ1,…,τk in the main function.

    lags = [1,0.2];
  5. Solve the DDE by calling dde23 in the main function. Pass the DDE function, the delays, the solution history, and interval of integration, [0,5], as inputs.

    sol = dde23(@ddex1de,lags,@ddex1hist,[0,5]);

    The dde23 function produces a continuous solution over the whole interval of integration [t0,tf].

  6. Plot the solution returned by dde23. Add this code to your main function.

    plot(sol.x,sol.y); title('An example of Wille and Baker'); xlabel('time t'); ylabel('solution y'); legend('y_1','y_2','y_3','Location','NorthWest');
  7. Evaluate the solution at 10 equally spaced points over the interval of integration. Then plot the the results on the same axes as sol.y. Add this code to the main function.

    tint = linspace(0,5,10); Sint = deval_r(sol,tint) hold on plot(tint,Sint,'o');
  8. Run your program to generate and plot the results.

matlab中dde23函数_时滞模型的matlab编程

代码如下:

ddex1dez = @(t,y,Z) [Z(1,1);Z(1,1)+Z(2,2);y(2)];

lags = [1,0.2];

sol = dde23(ddex1dez,lags,[1 1 1],[0,5]);

 

plot(sol.x,sol.y);
title(‘An example of Wille and Baker’);
xlabel(‘time t’); ylabel(‘solution y’);
legend(‘y_1′,’y_2′,’y_3′,’Location’,’NorthWest’);

 

tint = linspace(0,5,10);
Sint = deval(sol,tint)

hold on
plot(tint,Sint,’o’);

或者 按如下代码执行:

clear;clc

lags=[1,0.2];

history=[1;1;1];

tspan=[0,5];

sol = dde23(@myddefun,lags,history,tspan)

plot(sol.x,sol.y) 

function dy = myddefun(t,y,Z)
dy=[
    Z(1,1);
    Z(1,1)+Z(2,2);
    y(2) ];

引用:

http://blog.sina.com.cn/s/blog_3ecbcc0701013bcd.html

http://wenku.baidu.com/view/31c21f54cc1755270722088b.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/187033.html原文链接:https://javaforall.net

(0)
上一篇 2022年10月1日 下午6:16
下一篇 2022年10月1日 下午6:16


相关推荐

  • 数据库选型之内存数据库eXtremeDB

    数据库选型之内存数据库eXtremeDB鉴于内存数据库访问速率快的特点,本文分别从单线程、多线程(并发访问)和多线程读/写混合访问角度对eXtremeDB数据库读写速率展开测试。需要指出的是,本文读取操作包含将数据读取后,并在控制台显示出来

    2022年7月2日
    46
  • MySQL的存储过程_MySQL创建存储过程

    MySQL的存储过程_MySQL创建存储过程mysql存储过程详解

    2022年10月6日
    6
  • MATLAB图像识别_多模态图像配准

    MATLAB图像识别_多模态图像配准基于SIFT特征的图像配准(附Matlab源代码) 本文先给出了采用SIFT方法进行图像配准的实验原图以及实验结果,最后附上Matlab源代码。 实验一:      实验一的图像(见图1.1)是本人自己拍摄的,然后由软件裁剪成400×400像素而成,其中参考图像和待配准图像之间有重叠部分,且具有一定的旋转。这是一般难度的图像配准。

    2025年5月29日
    4
  • kali系统卸载Docker容器

    kali系统卸载Docker容器一 首先停止 Dockersystem docker service DockerApplic loaded lib systemd system docker service enabled vendor gt Active inactive dead sinceTue2022 03 2223 53 03CST 5sagoTrigger

    2026年3月26日
    2
  • HashMap的hash碰撞

    HashMap的hash碰撞看了看HashMap的源码,有些心得先写下,以便以后查看,不然又要忘了,但不知道对不对,希望没误人子弟吧。主要是解释下HashMap底层实现与如何解决hash碰撞的。HashMap底层是table数组,Entry是HashMap的内部类。可以看到HashMap的key与value实际是保存在Entry中的,next是下一个Entry节点。staticfinalEntry<…

    2022年6月22日
    33
  • Intellij IDEA创建web项目 [超详细]

    Intellij IDEA创建web项目 [超详细]接触 Java 有些年头了 相信大家已经忘记了怎么创建一个不使用构建工具和任何 JavaWeb 框架的原始 JavaWeb 项目 最近接触一个老项目 就是使用很原始的方式搭建的 虽然使用了 Spring 的技术 但是没有使用构建工具 手工管理庞大的依赖 Java 类库 而且还是 Eclipse 项目 习惯了 IDEA 不想再用回 Eclipse 而且对比把一个不使用构建工具创建的项目改成使用构建工具的项目工作量和带来的效益 决定还是先不要使用构建工具 只是改成 IDEA 项目

    2026年3月17日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号