Error with pdeCoefficient PDE toolbox

4 ビュー (過去 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 Center および File ExchangeBoundary Conditions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by