From: Wen Zhe on 12 Jan 2010 11:14 Hey all, I am trying to run the following code (taken from http://www.mathworks.com/access/helpdesk/help/techdoc/ref/pdepe.html): function pdex1 m = 0; x = linspace(0,1,20); t = linspace(0,2,5); sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t); % Extract the first solution component as u. 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)') % -------------------------------------------------------------- function [c,f,s] = pdex1pde(x,t,u,DuDx) c = pi^2; f = DuDx; s = 0; % -------------------------------------------------------------- function u0 = pdex1ic(x) u0 = sin(pi*x); % -------------------------------------------------------------- function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t) pl = ul; ql = 0; pr = pi * exp(-t); qr = 1; This basically solves a partial differential equation using the pdepe solver in Matlab. I saved this as an M file, ran it in the command but i keep getting the following error: ??? Undefined function or method 'speye' for input arguments of type 'double'. Error in ==> odemass at 17 massM = speye(length(y0)); Error in ==> ode15s at 267 [Mtype, Mt, Mfun, Margs, dMoptions] = odemass(FcnHandlesUsed,odeFcn,t0,y0,... Error in ==> pdepe at 289 [t,y] = ode15s(@pdeodes,t,y0,opts,pde,ic,bc,m,xmesh,xi,xim,zxmp1,xzmp1,varargin{:}); Error in ==> pdex1 at 5 sol = pdepe(0,@pdex1pde,@pdex1ic,@pdex1bc,x,t); Everything in the code is exactly the same as taken from the webpage. So what is the problem? What is this function speye that causes the error? Any help would be much appreciated. Thanks. For your information, i'm using Matlab 7.5.0 (R2007b) Jerry
|
Pages: 1 Prev: Time to frequency domain Next: Figures opening as logical variables |