非常数的系数PDE工具:错误告诉我,函数处理指定函数系数必须接受两个输入参数,并返回一个输出参数,但这是我的形式

5视图(30天)
大家好,我是试图解决一个系统1 d 2 PDE的非常数的系数(即系数依赖于x值和梯度),我指定一个函数的系数,然后想通过它specifyCoefficients解决我的PDE。我得到以下错误:
错误使用pde。CoefficientAssignment / checkCoefFcnHdlArgCounts(第531行)
函数处理指定系数必须接受两个输入参数和返回一个输出参数
我不明白的是为什么,因为这是形式,即矩阵=函数(地区、州)一个输出,两个输入。这是相关代码:
numberofPDE = 2;
模型= createpde (numberofPDE);
geometryFromEdges(模型中,g);
mhandle = @mcoeffunction;
specifyCoefficients(模型,“米”mhandle,“c”@ccoeffunction,' d 'd“一个”一个,“f”f);
applyBoundaryCondition(模型,“边缘”4“u”@boundary,矢量化的,“上”);
hmax = h / 16;
msh = generateMesh(模型,“Hmax”hmax,“MesherVersion”,“R2013a”);
结果= solvepde(模型);
地点:
函数Mmatrix = mcoeffunction(地区,~)
N = 4;
Nr =元素个数(region.x);
Mmatrix = 0 (N, Nr);
16 =宽度* (2 * density2 * (y2 ^ 5 * (- c22 ^ 2/5 + (2 * c32) / 5) - y3 ^ 5 * (- c22 ^ 2/5 + (2 * c32) / 5) - (y2 c22 * ^ 4) / 2 + (c22 * y3 ^ 4) / 2 - y2 ^ 3/3 + y3 ^ 3/3 - (c32 ^ 2 * y2 ^ 7) / 7 + (c32 ^ 2 * y3 ^ 7) / 7 + (c22 * c32 * y2 ^ 6) / 3 - (c22 * c32 * y3 ^ 6) / 3) - 2 * density1 * (y1 ^ 5 * (c21 ^ 2/5 + (2 * c31) / 5) - y2 ^ 5 * (c21 ^ 2/5 + (2 * c31) / 5) + (c21 * y1 ^ 4) / 2 - (y2 c21 * ^ 4) / 2 + y1 ^ 3/3 - y2 ^ 3/3 + (c31 y1 ^ ^ 2 * 7) / 7 - (c31 ^ 2 * y2 ^ 7) / 7 + (c21 * c31 * y1 ^ 6) / 3 - (c21 * c31 * y2 ^ 6) / 3) - density3 * ((2 * c33 ^ 2 * y3 ^ 7) / 7 - (4 * c33 * y3 ^ 5) / 5 + (2 * y3 ^ 3) / 3));
当=宽度* density3 * ((2 * c33 * y3 ^ 5) / 5 - (2 * y3 ^ 3) / 3) - 2 * density1 * ((c31 * y1 ^ 5) / 5 + (c21 * y1 ^ 4) / 4 + y1 ^ 3/3 - (c31 * y2 ^ 5) / 5 - (c21 * y2 ^ 4) / 4 - y2 ^ 3/3) - 2 * density2 * (- (c32 * y2 ^ 5) / 5 + (c22 * y2 ^ 4) / 4 + y2 ^ 3/3 + (c32 * y3 ^ 5) / 5 - (c22 * y3 ^ 4) / 4 - y3 ^ 3/3);
I2 =宽度* (- 2 * density1 * (y1 ^ 3/3 - y2 ^ 3/3) - 2 * density2 * (y2 ^ 3/3 - y3 ^ 3/3) - (2 * density3 * y3 ^ 3) / 3);
:Mmatrix (1) = i2 * 1 (1, N);
Mmatrix(2) =(((π/ (2 * L)) *罪(π* region.x. / (2 * L))) / (1-cos(π* region.x. / (2 * L)))) *预告;
:Mmatrix (4) = 16 * 1 (1, N);
结束
16、预告、I2只是数值。我试过与波浪号,没有波浪号,都没有区别。通常状态会有波浪字符,但它不是用在这里。我从Mmatrix得到这个错误,因为它是第一个检查。
谁知道这是怎么回事吗?问候,莱昂

接受的答案

Damian Sheehy
Damian Sheehy 2016年6月23日
你可能有一个语法错误在体内mcoeffunction函数和误差产生可能是误诊。我建议测试函数如下:
%设置一些数据传递给函数
systemsize = 1;
的位置。x = 0;
的位置。y = 0;
的位置。z = 0;
location.subdomain = 1;
状态。u = 0 (systemsize, 1);
状态。用户体验= 0 (systemsize, 1);
状态。uy = 0 (systemsize, 1);
状态。是乌斯= 0 (systemsize, 1);
状态。时间= 0;
现在%测试函数调用:
mhandle = @mcoeffunction;
结果= mhandle(位置、状态)

更多的答案(0)

社区寻宝

找到宝藏在MATLAB中央,发现社区如何帮助你!

开始狩猎!