pde23t error in chebfun
    4 次查看(过去 30 天)
  
       显示 更早的评论
    
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
    
 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 个)
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Boundary Conditions 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


