How can I enter a source term which is a vector, to solve -div(cgradu)=F(F a vector)?

조회 수: 3 (최근 30일)
Batoul
Batoul 2013년 12월 12일
답변: Bill Greene 2013년 12월 17일
Hello, I want to solve the pde (-div(cgrad(u))= F) with F given as a column vector of length N. I used the assempde to solve directly the pde with that F but it always answers me
??? Error using ==> plus Matrix dimensions must agree.
Error in ==> assempde at 245 KK=K+M+Q;
Error in ==> myprogram at 119 u=assempde(b,p,e,t,c,a,F);
Any help, please? Thank you in advance
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 12월 17일
At the MATLAB command line, command
dbstop if error
and then run the program. When it stops, what does size(K), size(M), size(Q) indicate? Then, give the command
dbup
and show size(b), size(p), size(e), size(t), size(c), size(a), size(F)

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

답변 (2개)

Bill Greene
Bill Greene 2013년 12월 12일
I assume N is > 1? How did you define the first argument to assempde, b? I'm guessing that the problem at line 245 of assempde is caused by K and M having a different size from Q where Q is calculated based on your boundary condition definition, b.
Bill
  댓글 수: 3
Bill Greene
Bill Greene 2013년 12월 13일
OK, well I suspect there is a problem in your pdebound function. There is no way to say more with only the information you have provided.
Bill
Batoul
Batoul 2013년 12월 17일
편집: Walter Roberson 2013년 12월 17일
Yes but when i give F as a constant(i.e. N=1), it works... and for the pdebound i used this
function [qmatrix,gmatrix,hmatrix,rmatrix] = pdebound(p,e,~,~)
ne = size(e,2); % number of edges
qmatrix = zeros(1,ne);
gmatrix = qmatrix;
hmatrix = zeros(1,2*ne);
rmatrix = hmatrix;
for k = 1:ne
hmatrix(k) = 1;
hmatrix(k+ne) = 1;
rmatrix(k) =0;
rmatrix(k+ne) =0;
end
since i have u=0 on the boundary
So, i can't find the mistake :(

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


Bill Greene
Bill Greene 2013년 12월 17일
Yes, your pdebound function is incorrect for a system of PDE (N>1). Specifically, as this documentation page shows,
the returned matrices must have these dimensions (for this example, N=3):
N = 3; % Set N = the number of equations
ne = size(e,2); % number of edges
qmatrix = zeros(N^2,ne);
gmatrix = zeros(N,ne);
hmatrix = zeros(N^2,2*ne);
rmatrix = zeros(N,2*ne);
I recommend taking a close look at the www page I list above so you can see exactly how those matrices must be defined.
Bill

카테고리

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