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

3 visualizzazioni (ultimi 30 giorni)
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 Commento
Walter Roberson
Walter Roberson il 17 Dic 2013
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)

Accedi per commentare.

Risposte (2)

Bill Greene
Bill Greene il 12 Dic 2013
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 Commenti
Bill Greene
Bill Greene il 13 Dic 2013
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 il 17 Dic 2013
Modificato: Walter Roberson il 17 Dic 2013
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 :(

Accedi per commentare.


Bill Greene
Bill Greene il 17 Dic 2013
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

Community Treasure Hunt

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

Start Hunting!

Translated by