フィルターのクリア

Error using integral2

2 ビュー (過去 30 日間)
Shahid Hasnain
Shahid Hasnain 2018 年 11 月 15 日
コメント済み: Star Strider 2018 年 12 月 3 日
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 件のコメント
Shahid Hasnain
Shahid Hasnain 2018 年 11 月 15 日
Ntruc=100;
number of trunction terms. We say as 100.
madhan ravi
madhan ravi 2018 年 11 月 15 日
see my answer below

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2018 年 11 月 15 日
編集済み: Star Strider 2018 年 11 月 15 日
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 件のコメント
Shahid Hasnain
Shahid Hasnain 2018 年 12 月 3 日
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 2018 年 12 月 3 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by