How I introduce a matrix form of c coefficient in PDE equation using solvepde matlab command

조회 수: 6 (최근 30일)
Hello,
please how I introduce the c coeffecient which is has a matrix form:
c = [x-y, 0; 1, x.^2]
using "specifyCoefficients" and "solvepde" matlab command?
With best regards
I try this code
%======================================
numberOfPDE = 1;
model = createpde(numberOfPDE);
r1 = [3,4,0,0,0.5*10^-6,0.5*10^-6,-160*10^-9,-1.16*10^-6,-1.16*10^-6,-160*10^-9];
r2 = [3,4,0,0,0.5*10^-6,0.5*10^-6,0,-160*10^-9,-160*10^-9,0];
gdm = [r1; r2]';
g = decsg(gdm,'R1+R2',['R1'; 'R2']');
geometryFromEdges(model,g);
C = @(location,~)[location.x-location.y,0;1,location.x.^2];
F=@(location,~)location.x;
specifyCoefficientsspecifyCoefficients(model,'m',0,'d',0,'c',C,'a',0,'f',F);
msh = generateMesh(model,'Hmax',0.02,'GeometricOrder','linear','Jiggle','on');
pdeplot(model);
[p,e,t] = meshToPet(msh);
results = solvepde(model)
%==================================================================
and I obtain the error message:
Error using formGlobalKF2D
Coefficient evaluation function, "@(location,~)[location.x-location.y,0;1,location.x.^2]", was requested to calculate
coefficients at 1 locations so should have returned a matrix with 1 columns. Instead it returned a matrix with 2 columns.

답변 (1개)

Ravi Kumar
Ravi Kumar 2019년 7월 2일
Output of c coefficient function should be a matrix or column vector of appropriate size, where the number of columns corresponds to spatial locations as provided by location.x and location.y. Try this:
C = @(location,~)[location.x-location.y; ...
ones(size(location.x));...
zeros(size(location.x));...
location.x.^2];

카테고리

Help CenterFile Exchange에서 Geometry and Mesh에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by