MATLAB Matrix construction advice -


i need use matlab solve following matrix equation:

matrix equation

this matrix nxn, , can construct of matrix using following matlab code:

e = ones(n,1); = h^(-2)*spdiags([e (h^2 - 2)*e e], [-1 0 1], n, n); 

what's way change first , last row? perhaps nice add nice matrix b first row [ 2/h 1/h^2 0 ... 0 0 0 ] , last row [ 0 0 0 ... 0 1/h^2 (2h + 1)/h^2] , take + b. how though?

i think simplest way best in case aren't modifying of matrix have created:

a(1,:)=a(1,:)+[2/h 1/h^2 zeros(1,n-2)]; a(n,:)=a(n,:)+[zeros(1,n-2) 1/h^2 2/h]; 

or replace individual elements rather rows.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -