如何将时间相关变量包含到 Scilab 的 ode-solver 中? [英] How to include time dependent variables into ode-solver in Scilab?

查看:68
本文介绍了如何将时间相关变量包含到 Scilab 的 ode-solver 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在求解非线性 ODE 系统.这是一组运动学运动方程,我需要在其中计算给定角速度的位置角

I am currently solving a system of nonlinear ODE's. It is a set of kinematic motion equations, where I need to calculate the position angles with given anguar velocities

我发现如何使用列表添加依赖于时间的函数,但问题是,如何添加一个也依赖于时间但作为向量给出的参数.

I found out, how to add a function dependent on time using the list, but the question is, how to add a parameter which is also time dependent, but given as a vector.

简化是用下面的代码写的.c(t) 是一个时间函数.

Simplified is it written in the following code. c(t) is a time function.

function dx = f(t, x, c)

dx(1) = x(1)*sin(x(2))
dx(2) = c*x(2)*cos(x(1))
dx(3) = t*cos(x(3))
endfunction

c = 1:32; // values from measured signal, here simplyfied

y0 = [0.1;0.1;0.1];

t0 = 0;

t = 0:0.1:%pi;

y = ode(y0, t0, t, list (f, c));

推荐答案

关于如何将函数表转换为插值函数.

on how to convert a function table into an interpolating function.

本质上,在右侧函数 dx=f(t,x,tc_arr) 中,您评估

Essentially, in the right side function dx=f(t,x,tc_arr) you evaluate

function dx=f(t,x,tc_arr)
  c = interpln(tc_arr, t)
  dx(1) = x(1)*sin(x(2))
  dx(2) = c*x(2)*cos(x(1))
  dx(3) = t*cos(x(3))
endfunction

其中 tcarr 包含采样时间和采样值的数组.

where tcarr contains arrays of sampling times and sampling values.

以信号为例

t_sam = -1:0.5:4;
c_sam = sin(2*t_sam+1);

tc_arr = [ t_sam; c_sam ];

请注意,您始终需要采样时间来了解输入时间 t 与值数组的关系.

Note that you always will need the sample times to find out how the input time t relates to the value array.

t = 1.23;
c = interpln(tc_arr, t)

返回c = - 0.2719243.

您也可以使用其他函数,它在插值方法方面有更多选择.

You could as well use the other function, which has more options in terms of interpolation method.

function dx=f(t,x,t_sam,c_sam)
  c = interp1(t_sam, c_sam, t, "spline", "extrap")
  dx(1) = x(1)*sin(x(2))
  dx(2) = c*x(2)*cos(x(1))
  dx(3) = t*cos(x(3))
endfunction

这篇关于如何将时间相关变量包含到 Scilab 的 ode-solver 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆