elliptic PDE with variable coefficient

2 ビュー (過去 30 日間)
ann
ann 2014 年 11 月 19 日
編集済み: ann 2014 年 11 月 19 日
Hello,
I am desperately trying to solve the following equation (in 2D) :
-(laplacian)u + u =1
This is basically an elliptic PDE with
c=1 , f=1 and a= B(x,y).
B(x,y) is a function I have created that doesn't have any closed form. Here's the code for B(x,y):
I entered c=1 , f=1 and a= B(x,y) in the pde specification but I cannot solve the equation as I get the following error
Expression evaluates to wrong size. Must be scalar or row vector. In a system case, pass first or second row; for example u(2,:)
Can somebody help me fix this ?
Thank you
  2 件のコメント
Geoff Hayes
Geoff Hayes 2014 年 11 月 19 日
Ann - please describe what you mean by I entered c=1 , f=1 and a= V(x,y). in the pde specification but I cannot solve the equation as I get the following error. What line of code are you calling that generates the error? What is the pde specification?
ann
ann 2014 年 11 月 19 日
I was talking about the PDE toolbox in Matlab. In the PDE toolbox, you can choose the type of the equation you are trying to solve (in the menu -> PDE -> PDE specifications ..). Here my equation is an elliptic one : ie. it takes the form
-div(c*grad(u))+a*u=f
so I chose
c=1 , a= V(x,y) , f=1

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

採用された回答

Bill Greene
Bill Greene 2014 年 11 月 19 日
The input arguments, x and y are equal length row vectors of x and y coordinates where the a coefficient must be defined. If this length (number of columns) is n, the output argument, v, must be a matrix with dimensions 1 x n (i.e. a row vector). The line
v = M(intx,inty);
is returning an n x n matrix; that is the reason for the error message.
  3 件のコメント
Bill Greene
Bill Greene 2014 年 11 月 19 日
Yes, x and y are spatial locations in the mesh where the a-coefficient must be defined. The returned value must be a row vector with values at just those points. You are returning a matrix with n x n points where what is required is a row vector with values at the n locations. The simplest way to understand and implement this (though not particularly efficient) is with this snippet of code:
v = zeros(1, length(x))
for i=1:length(x)
v(i) = M(intx(i), inty(i));
end
ann
ann 2014 年 11 月 19 日
編集済み: ann 2014 年 11 月 19 日
Thank you

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by