我如何使用NxM矩阵作为我在`pdepe`中的初始条件 [英] How can I use NxM matrix to be my initial condition in `pdepe`

查看:327
本文介绍了我如何使用NxM矩阵作为我在`pdepe`中的初始条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Matlab解算器pdepe解决了PDE.初始条件是ODE的解决方案,我在另一个m.file中解决了该问题.现在,我有了大小为NxM的矩阵形式的ODE解决方案.我如何使用它作为pdepe中的IC?那有可能吗?当我使用for loop时,pdepe仅将最后一次迭代作为初始条件.感谢您的帮助.

I solved a PDE using Matlab solver, pdepe. The initial condition is the solution of an ODE, which I solved in a different m.file. Now, I have the ODE solution in a matrix form of size NxM. How I can use that to be my IC in pdepe? Is that even possible? When I use for loop, pdepe takes only the last iteration to be the initial condition. Any help is appreciated.

推荐答案

每个 pdepe文档,求解器的初始条件函数具有以下语法:

Per the pdepe documentation, the initial condition function for the solver has the syntax:

u = icFun(x);

其中,在列向量u中返回指定值x的PDE初始值. 因此,只有当PDE是具有M个空间网格点的N未知数的系统时,初始条件才会是N x M矩阵.

where the initial value of the PDE at a specified value of x is returned in the column vector u. So the only time an initial condition will be a N x M matrix is when the PDE is a system of N unknowns with M spatial mesh points.

因此,可以使用N x M矩阵来填充初始条件,但是将需要一些映射将给定列与特定值x相关联.例如,在调用pdepe的主函数中,可能有

Therefore, an N x M matrix could be used to populate the initial condition, but there would need to be some mapping that associates a given column with a specific value of x. For instance, in the main function that calls pdepe, there could be

% icData is the NxM matrix of data
% xMesh is an 1xM row vector that has the spatial value for each column of icData
icFun = @(x) icData(:,x==xMesh);

此方法的唯一缺点是初始条件的网格以及pdepe解均受初始数据约束.可以通过使用类似以下的插值方案来解决:

The only shortcoming of this approach is that the mesh of the initial condition, and therefore the pdepe solution, is constrained by the initial data. This can be overcome by using an interpolation scheme like:

% icData is the NxM matrix of data
% xMesh is an 1xM row vector that has the spatial value for each column of icData
icFun = @(x) interp1(xMesh,icData',x,'pchip')';

其中出现转置以符合 interp1 .

where the transposes are present to conform to the interpretation of the data by interp1.

这篇关于我如何使用NxM矩阵作为我在`pdepe`中的初始条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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