calling a function pdepe

2 次查看(过去 30 天)
Matt
Matt 2014-7-29
i am using pdepe to solve a coupled PDE.
m = 0; x = linspace(0,1,20); t = linspace(0,2,5);
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
u = sol(:,:,1);
% A surface plot is often a good way to study a solution.
surf(x,t,u)
title('Numerical solution computed with 20 mesh points.')
xlabel('Distance x')
ylabel('Time t')
% A solution profile can also be illuminating.
figure
plot(x,u(end,:))
title('Solution at t = 2')
xlabel('Distance x')
ylabel('u(x,2)')
The boundary and initial conditions are saved in another two separate files files as below
function u0 = pdex1ic(x)
u0 = sin(pi*x);
function [c,f,s] = pdex1pde(x,t,u,DuDx)
c = pi^2;
f = DuDx;
s = 0;
My question is I want to plot c,f,s. How can i call them in the mail finction. I try to call like [c] = pdex1pde(x,t,u,DuDx); in the main functon but it says me undefine DuDx.?
Any help appriciated.
Thanks
  1 个评论
Geoff Hayes
Geoff Hayes 2014-7-29
Matt - I gather that you want to plot the result of pdex1pde but am not sure where you want to try and plot this. What is the main function? Please update your above code to indicate where you have put the line to try and plot the data. As well, please format the code by highlighting it and pressing the {}Code button.
I don't understand the purpose of pdex1pde since it ignores the first three inputs...

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 1-D Partial Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by