2
$\begingroup$

I'm trying to construct the right–hand side of my 2D Poisson's equation in Matlab. I used the vertex rule in order to approximate the integral:

function F1 = rightVer(p,t,f)

%area triangle
it1=t(1,:);
it2=t(2,:);
it3=t(3,:);
area = ((p(1,it2)-p(1,it1)).*(p(2,it3)-p(2,it1))-(p(1,it3)-p(1,it1)).*(p(2,it2)-p(2,it1)))/2;

area = abs(area)/3;
vt1 = area.*f(p(1,it1),p(2,it1));
vt2 = area.*f(p(1,it2),p(2,it2));
vt3 = area.*f(p(1,it3),p(2,it3));

vt = [vt1';vt2';vt3'];
elem = t';
elem(:,4)=[];
N=size(p,2);
F1  =  accumarray(elem(:),vt,[N  1]);
end

I also construct it with the pde toolbox with the function assema() but the two f which I obtained are the same except for the last 4 numbers. Can anyone help me?

$\endgroup$

closed as unclear what you're asking by Anton Menshov Jun 16 at 23:10

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ It is unclear what question is being asked. Asking for debugging help with a chunk of code isn't searchable and isn't likely to help other people. This site works better when you pose questions that may be encountered by other people attempting to do similar things. $\endgroup$ – Jed Brown Dec 1 '13 at 15:30
  • 1
    $\begingroup$ Where are the last 4 nodes? What is p(end-4:end,:)? Are those nodes on boundary? Mostly like MATLAB already modified the Dirichlet boundary's load. $\endgroup$ – Shuhao Cao Dec 2 '13 at 17:23