pde23t error in chebfun

조회 수: 4 (최근 30일)
Oluwaseun Lijoka
Oluwaseun Lijoka 2016년 3월 26일
답변: Walter Roberson 2016년 3월 29일
Hello there, I am using chebfun to approximate a system of pde but I discover that the pde23t solver does not allow any other argument especially when the initial conditions are written in a M-function file to be passed into the pde23t solver. Is there anyway one can pass the initial condition as an output of a function Here is my code below:
function f=chebbasis(i,alpha,N,p)
%%chebwave.m -- an executable m-file for solving a partial differential equation
%
% Solving
% u_t = v
% v_t = u''-alpha*v,,
% for x in [A,B] and t in chebpts, subject to
% u(t,A) = u0(A)+t*v0(A) at x = A
% u(t,B) = u0(B)+t*v0(B) at x = B
%%Problem set-up
% Create an interval of the space domain...
A=-1; B=2;
dom = [A B];
%...and specify a sampling of the time domain:
KIND=1;
t = chebpts(N,[0,1],KIND); % Using scaled cheb pts on [0,1] for the time
% Make the right-hand side of the PDE.
pdefun = @(t,x,u,v) [v; diff(u,2)-alpha*v];
% Construct a chebfun of the space variable on the domain,
x = chebfun(@(x) x, dom);
% and of the initial conditions.
sol0 = initcheb(i,x,p);% my initial condition
% Assign boundary conditions.
solA=initcheb(i,A,p) ; solB=initcheb(i,B,p) ;
bc.left = @(t,u,v) u-solA(1)-t*solA(2);
bc.right = @(t,u,v) u-solB(1)-t*solB(2);
%%Setup preferences for solving the problem.
opts = pdeset('Eps', 1e-6, 'Ylim', [0,1]);
%%Call pde23t to solve the problem.
[~, u, ~] = pde23t(pdefun, t, sol0, bc, opts);
f=chebfun2('u',[0 1 0 1]); want to write the function as u(x,t) is it possible??
%%Plot the solution components.
% figure(2)
plot(u)
%%%%%%%%Initial condition%%%%
function sol0 = initcheb(i,x,p)
j=i-1; q=j-1;
if (0<=j) && (j<=p)
u0 =x.^j;
v0 = -j*x.^q ;
elseif (p+1<=j)&&(j<=2*p);
j=j-p; q=j-1;
u0=x.^j; v0= j*x.^q;
end
sol0 = [u0, v0];
Here is the error code:
Error using chebfun/merge
Too many input arguments.
Error in chebfun/pdeSolve (line 587)
u0(k) = merge(u0(k), 'all', 1025, tol);
Error in chebfun/pde23t (line 31)
[varargout{1:nargout}] = pdeSolve(varargin{:});
Error in chebbasis (line 53)
[~, u, ~] = pde23t(pdefun, t, sol0, bc, opts);
  댓글 수: 1
Vidya Viswanathan
Vidya Viswanathan 2016년 3월 29일
Hi,
I believe that you downloaded the latest version of "chebfun" either from their official web page http://www.chebfun.org/ or from the MATLAB Central submission located at http://www.mathworks.com/matlabcentral/fileexchange/47023-chebfun-current-version . I suppose it would be better if you could post the same question as a comment in their MATLAB central submission or reach out to them at "help@chebfun.org" as well. The author of the submission might be able to get back to you quickly with a resolution to your query.
Regards,
Vidya

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2016년 3월 29일

카테고리

Help CenterFile Exchange에서 Boundary Conditions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by