Error using integral2

3 views (last 30 days)
Shahid Hasnain
Shahid Hasnain on 15 Nov 2018
Commented: Star Strider on 3 Dec 2018
I have following expression with
x=[1 2 3 4 5]
y=[1 2 3 4 5]
L = 100; % Length of the box
p=1;
q=1;
Ui = @(x,y) sin(pi*x).*sin(pi*y); % An initial distribution for u, i.e. the u(x,y,0)
Vi = @(x,y) sin(pi*x).*sin(pi*y); % An initial distribution for v, i.e. the v(x,y,0)
Wi = Ui(x,y) + Vi(x,y); % Initial condition for w, i.e. w(x,y,0)
% Computation of the b-coefficients
if p < Ntrunc
if q < Ntrunc
my_integrand = @(x,y) 4*Wi.*sin(p.*x).*cos(q.*y)/L^2;
bd(p,q) = integral2(my_integrand(x,y),0,L,0,L);
q = q+1;
end
p = p+1;
end
I got following error,
Error using integral2Calc>integral2t/tensor (line 231)
Input function must return 'double' or 'single' values. Found 'function_handle'.
Error in integral2Calc>integral2t (line 55)
[Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT);
Error in integral2Calc (line 9)
[q,errbnd] = integral2t(fun,xmin,xmax,ymin,ymax,optionstruct);
Error in integral2 (line 106)
Q = integral2Calc(fun,xmin,xmax,yminfun,ymaxfun,opstruct);
Correction will be highly appreciated.
  3 Comments
Shahid Hasnain
Shahid Hasnain on 15 Nov 2018
Ntruc=100;
number of trunction terms. We say as 100.
madhan ravi
madhan ravi on 15 Nov 2018
see my answer below

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 15 Nov 2018
Edited: Star Strider on 15 Nov 2018
This works, although it throws a warning:
Ntrunc = 100;
L = 100; % Length of the box
p=1;
q=1;
Ui = @(x,y) sin(pi*x).*sin(pi*y); % An initial distribution for u, i.e. the u(x,y,0)
Vi = @(x,y) sin(pi*x).*sin(pi*y); % An initial distribution for v, i.e. the v(x,y,0)
Wi = @(x,y) Ui(x,y) + Vi(x,y); % Initial condition for w, i.e. w(x,y,0)
% Computation of the b-coefficients
if p < Ntrunc
if q < Ntrunc
my_integrand = @(x,y) 4*Wi(x,y).*sin(p.*x).*cos(q.*y)/L^2;
bd(p,q) = integral2(@(x,y)my_integrand(x,y),0,L,0,L);
q = q+1;
end
p = p+1;
end
I defer to you to correct the problem that produces the warning.
EDIT — Corrected typographical error.
  10 Comments
Shahid Hasnain
Shahid Hasnain on 3 Dec 2018
Sorry for being late.
I am trying to solve Gray Scott Model in 2 dimension by analytical technique. the code I attached few days back, it was a try to find analytical solution.
Here is the system
u_t = u_{xx} + u_{yy} - uv^2 + 1 - u
v_t = v_{xx} + v_{yy} + uv^2 - v
I do not have analytical solution to this problem, thats why we choose another way to find.
w=u+v (wexact_Patrick, it was mentioned in previous posts) working
d=u-v (it was mentioned in previous posts) half working still.
Still working to rearrange integral3 which create problems.
Star Strider
Star Strider on 3 Dec 2018
No worries about a delayed reply.
Do you want to integrate a system of partial differential equations? If so, please post this as a new Question. My experience with the Partial Diufferential Equation Toolbox is limited, although Torsten and some others here likely have significant experience with it. I have not worked with it in a while, so it would take some time for me to provide you with a response.

Sign in to comment.

More Answers (0)

Categories

Find more on Systems of Nonlinear Equations in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!