satansdisciple14
satansdisciple14

Reputation:

Writing PDEs in MATLAB

I'm a completely new user to Matlab. I want to calculate PDEs like this one: PDE But I have no idea how to code it. I have tried g(x)=diff(x,y)^2/(diff(x)*diff(y)); but it doesn't work.

Upvotes: 0

Views: 509

Answers (1)

MichaelTr7
MichaelTr7

Reputation: 4767

By using the symbolic toolbox and diff() function the partial derivatives can be simplified as follows. I'm not sure if you'd like to solve any specific values or plots but going based on the image posted here are some techniques that may help.

Example Partial Derivatives of Function f Taken with Respect to X and Y:

%Creating symbolic variables/representations%
syms x y

%Function dependent on variables x and y%
f = 2*y*sin(5*x);

%Taking the partial derivative with respect to x%
g = diff(f,x);
%Taking the partial derivative with respect to y%
g = diff(g,y)

Example Equation:

Equations

Extension: Graphing

Plotting the original function and its derivative can be done by using the fsurf() function which plot symbolic functions.

Plotting Symbolic Functions

%Plotting the symbolic result of the partial derivatives%
subplot(1,2,1); fsurf(f);
title('Original Function');
xlabel('X-Axis'); ylabel('Y-Label');

subplot(1,2,2); fsurf(g);
title('Derivative of Function');
xlabel('X-Axis'); ylabel('Y-Label');

Extension: Evaluating at Specific Values

%Evaluating partial derivative at specific values%
x = 1;
y = 1;
Answer = subs(g);
Answer_As_A_Double = double(Answer);

Using MATLAB version: R2019b

Upvotes: 1

Related Questions