Error with pdeCoefficient PDE toolbox

4 views (last 30 days)
Edoardo Saccenti
Edoardo Saccenti on 12 Feb 2022
Commented: Edoardo Saccenti on 17 Feb 2022
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];

Answers (1)

Pratyush Roy
Pratyush Roy on 16 Feb 2022
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 Comment
Edoardo Saccenti
Edoardo Saccenti on 17 Feb 2022
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

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!