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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Exception和Error的理解

    Exception和Error的理解

    2021年6月9日
    92
  • C#中,判断一个字符串是否为数字

    C#中,判断一个字符串是否为数字

    2021年8月10日
    46
  • 多线程中线程锁的使用

    多线程中线程锁的使用在多线程的程序编写中,常常遇到共享资源使用冲突解决的苦恼。终于看到并测试了一种简单方法。线程锁的5个要素:CRITICAL_SECTIONg_cs; //定义线程锁InitializeCriticalSection(&g_cs);  //初始化DeleteCriticalSection(&g_cs);  //删除EnterCriticalSection(&g_c…

    2022年6月21日
    20
  • 美国空间Hostease支付宝人民币购买教程图解[通俗易懂]

    美国空间Hostease支付宝人民币购买教程图解[通俗易懂]这段时间买国外主机的筒子们越来越多,而付款就是首先摆在大家眼前的一道障碍,大部分美国主机商只能通过信用卡购买,付款不方便,因此能够使用支付宝支付的主机商也备受关注。而目前全球支持支付宝付款的美国主机商一共就三家,分别是ixwebhosting、Godaddy、HostEase。第二道障碍就是网站英文界面问题,目前只有ixwebhosting开通了中文站点,因此大家购买ixwebhost…

    2022年10月18日
    0
  • 方舟:生存进化PVE模式和PVP模式

    方舟:生存进化PVE模式和PVP模式这个模式会比较适合新手玩家 在现实世界中可能会有些自己想做的事情 但并不能随心所欲 通过 PVE 模式主要了解龙的特性以及游戏的玩法 怎么建造自己的家园强大起来 PVE 模式和 PVP 模式的区别主要就在玩法的不同 各位大佬可以根据自己喜欢的模式来进行游玩 看看自己比较适合哪种模式再进行选择 在这个模式中 玩家与玩家之间可以是对手也可以是队友关系 一起进攻某个部落世界 一起打造一个强大的恐龙帝国 玩家与玩家直接的战斗 可以摧毁别人可能花了一个月的时间打造的部落 龙与龙之间的战斗 斗智斗勇

    2025年6月3日
    0
  • sql的日期格式化「建议收藏」

    sql的日期格式化「建议收藏」sql的日期格式化转化1.DATE_FORMAT()函数用于以不同的格式显示日期/时间数据。DATE_FORMAT(date,format)%a 缩写星期名%b 缩写月名%c 月,数值%D 带有英文前缀的月中的天%d 月的天,数值(00-31)%e 月的天,数值(0-31)%f 微秒%H 小时(00-23)%h 小时(01-12)%I 小时(01-12)%i 分钟,数值(00-59)%j 年的天(001-366)%k 小时(0-23)%l 小时(1-12)

    2022年10月7日
    0

发表回复

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

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