# nonlinear coefficient in custom PDE.

3 views (last 30 days)
Prakhar Sharma on 14 Jun 2022
I am trying to solve a variation of 2D steady state heat conduction PDE using PDE toolbox
Here , to simulate nonlinear behaviour.
Here is my code.
syms T(x,y)
syms k
pdeeq = diff(diff(T,x),x) + k*diff(diff(T,y),y)
symCoeffs = pdeCoefficients(pdeeq,T,'Symbolic',true)
symVars = [k]
symVals = [@(~,state) 0.01+1*state.u];
symCoeffs = subs(symCoeffs,symVars,symVals);
I get the following error, which does make sense
Error using sym/subs>normalize
Substitution expression X must be a symbolic, cell, or numeric array.
[X2,Y2,symX,symY] = normalize(X,Y); %#ok
Error in sym/subs (line 153)
Error in sym/subs>@(value)subs(value,X,Y) (line 64)
G = structfun(@(value) subs(value, X, Y), F, 'UniformOutput', false);
Error in sym/subs (line 64)
G = structfun(@(value) subs(value, X, Y), F, 'UniformOutput', false);
In case of standard heat transfer I can write this.
k = @(~,state) 0.01+1*state.u
thermalProperties(model,'ThermalConductivity', k);
How to do the same with my custom PDE?

Hi Prakhar,
I understand that you would like to model a custom PDE. The error "Substitution expression X must be a symbolic, cell, or numeric array." is caused due to the passing of a function handle instead of a Symbolic Variable to the "subs" function. An alternate way to model this PDE is as shown below:
syms T(x,y)
syms k
pdeeq = diff(diff(T,x),x) + k*diff(diff(T,y),y) == 0
symCoeffs = pdeCoefficients(pdeeq,T,'Symbolic',true)
symVars = k
symVals = x+10*y^2 % Assuming the variable 'k' is some nonlinear function of x and y
pdeeq = subs(pdeeq,symVars,symVals) % Directly updating the equation pdeeq with new variable
Post this, the PDE can be solved using the "solve" function with appropriate boundary conditions. You can refer to the following documentation to know more about “solve” function..
Hope this helps in resolving your issue.

### Categories

Find more on Heat Transfer in Help Center and File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!