ode matlab传递变量,一个时变ode求解例子——以及如何向myode传递附加参数

该示例展示了如何在MATLAB中解决一个包含时间依赖项的常微分方程。通过插值数据集定义的时间依赖参数f(t)和g(t),并编写M文件函数myode,将这些参数传递给ode45进行求解。最终,对解决方案y(t)进行绘图展示。
摘要由CSDN通过智能技术生成

//matlab2011b帮助文档自带的。

Example 3

This example solves an ordinary differential equation with

time-dependent terms.

Consider the following ODE, with time-dependent parameters

defined only through the set of data points given in two

vectors:

y'(t) + f(t)y(t) = g(t)

The initial condition is y(0) = 0, where the function

f(t) is defined through the n-by-1

vectors tf and f, and the function g(t)

is defined through the m-by-1 vectors tg

and g.

First, define the time-dependent parameters f(t) and

g(t) as the following:

ft = linspace(0,5,25); % Generate t for f

f = ft.^2 - ft - 3; % Generate f(t)

gt = linspace(1,6,25); % Generate t for g

g = 3*sin(gt-0.25); % Generate g(t)

Write an M-file function to interpolate the data sets specified

above to obtain th

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值