Error with pdeCoefficient PDE toolbox

조회 수: 7 (최근 30일)
Edoardo Saccenti
Edoardo Saccenti 2022년 2월 12일
댓글: Edoardo Saccenti 2022년 2월 17일
I am following this Matlab example to code my system of PDE (reequire PDE toolbox)
syms u1(x,y) u2(x,y)
pdeeq = [-laplacian(u1) + u2; -D*laplacian(u2) - pres];
symCoeffs = pdeCoefficients(pdeeq,[u1 u2],'Symbolic',true)
But if Try my Equation, I get an error and I cannot understand why. Any clue?
syms u1(t,x) u2(t,x)
pdeeq = [diff(u1,t) -laplacian(u1) + u2 == 0; diff(u2,t) -laplacian(u2) -u1 ==0];
symCoeffs = pdeCoefficients(pdeeq,[u1 u2],'Symbolic',true)
Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-2.
Error in sym/privsubsasgn (line 1229)
L_tilde2 = builtin('subsasgn',L_tilde,struct('type','()','subs',{varargin}),R_tilde);
Error in sym/cat>catMany (line 42)
y = privsubsasgn(y,arrays{k},subs{:});
Error in sym/cat (line 25)
ySym = catMany(dim, args);
Error in sym/vertcat (line 19)
ySym = cat(1,args{:});
Error in untitled (line 7)
pdeeq = [diff(u1,t) -laplacian(u1) + u2 == 0; diff(u2,t) -laplacian(u2) -u1 ==0];

답변 (1개)

Pratyush Roy
Pratyush Roy 2022년 2월 16일
Hi Edoardo,
As a workaround, you can try removing the equality operator and express the equations as a function of the variables. You can also express the equations in terms of the variables x and y instead of using t.
The script below might be helpful:
syms u1(x,y) u2(x,y)
pdeeq = [diff(u1,x)-laplacian(u1) + u2; diff(u2,y)-laplacian(u2)-u1*x];
symCoeffs = pdeCoefficients(pdeeq,[u1 u2],'Symbolic',true)
Hope this helps!
  댓글 수: 1
Edoardo Saccenti
Edoardo Saccenti 2022년 2월 17일
thanks for your answer. Indeed this work but if i modify to
syms u1(x,t) u2(x,t) % or u1(t,x) u2(t,x)
pdeeq = [diff(u1,t)-laplacian(u1) + u2; diff(u2,t)-laplacian(u2)-u1*x];
symCoeffs = pdeCoefficients(pdeeq,[u1 u2],'Symbolic',true)
will not work:
Index exceeds the number of array elements. Index must not exceed 1.
Error in sym/privsubsref (line 1201)
R_tilde = builtin('subsref',L_tilde,struct('type','()','subs',{varargin}));
Error in sym/pdeCoefficients>extractC/extractblock3D (line 226)
y = privsubsref(xy, 2);
Error in sym/pdeCoefficients>extractC/extractblock (line 174)
[bl, remainder] = extractblock3D(eq, U, xy);
Error in sym/pdeCoefficients>extractC (line 283)
[cblocks{n, p}, remainder] = extractblock(temp, privsubsref(u, p), xy);
Error in sym/pdeCoefficients (line 63)
[equations, C] = extractC(eq, fU);
Error in untitled2 (line 4)
symCoeffs = pdeCoefficients(pdeeq,[u1 u2],'Symbolic',true)
Index exceeds the number of array elements. Index must not exceed 1.
Error in sym/privsubsref (line 1201)
R_tilde = builtin('subsref',L_tilde,struct('type','()','subs',{varargin}));
Error in sym/pdeCoefficients>extractC/extractblock3D (line 226)
y = privsubsref(xy, 2);
Error in sym/pdeCoefficients>extractC/extractblock (line 174)
[bl, remainder] = extractblock3D(eq, U, xy);
Error in sym/pdeCoefficients>extractC (line 283)
[cblocks{n, p}, remainder] = extractblock(temp, privsubsref(u, p), xy);
Error in sym/pdeCoefficients (line 63)
[equations, C] = extractC(eq, fU);
Error in untitled2 (line 4)
symCoeffs = pdeCoefficients(pdeeq,[u1 u2],'Symbolic',true)
Any clue?
Thanks again
Edo

댓글을 달려면 로그인하십시오.

카테고리

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