7 years, 4 months ago.

VERY hard matlab problem

Hi guys,

I'm trying to make a 16-by-16 matrix with boundary conditions. Its a PDE/Poisson's equation problem. I can't seem to apply the conditions and plot this. At the top the values are 0 but at the bottom its 20*sin(pi*i/nx).

Boundary 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16-by-16 matrix - - - - - - - - - - - - - - - - - Boundary 2 20*sin(pi*1/16),20*sin(pi*2/16),...,20*sin(pi*16/16)

Here is the code I've written: N=16; M=16;

dx=1; dy=1; A = zeros(N*M); for i =1:N*M A(i,i) = -2*(1/dx^2 + 1/dy^2); end for i=1:N-1 for j=1:M A(i+(j-1)*N, i+(j-1)*N+1) = 1/dx^2; A(i+(j-1)*N+1, i+(j-1)*N )= 1/dx^2; end end

for i=1:N for j=M-1 A(i+(j-1)*N,i+j*N)=1/dy^2; A(i+j*N, i+(j-1)*N)=1/dy^2; end end

I've been struggling on this all day pls help! :'(

Maybe you'll get more luck if you try a matlab forum rather than an embedded programming forum.

posted by Andy A 05 Dec 2016
Be the first to answer this question.