O'Reilly logo

GNU Octave by Jesper Schmidt Hansen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – solving a two-dimensional Laplace equation

  1. We start by specifying the temperature at the edges of the plate, the number of grid points, and the spatial coordinate (recall that the package only supports square domains such that y = x):
    octave:16> T_0 = 300; N_grids = 50; L = 0.1; x = linspace(0, L,N_grids);
    
  2. The source term is zero:
    octave:17> B = zeros(N_grids, N_grids);
    
  3. The boundary conditions can be specified as:
    octave:18> B(:,1) = sin(pi*x/L) + T0; B(1,:) = T0; (N_grids,:)=T0;B(:,N_grids)=T0;
    
  4. To convert B into the appropriate vector format, we use the vecmat_convert function(Code Listing 6.3):
    octave:19> b = vecmat_convert(B);
    
  5. The coefficient matrix is generated via the command:
    Octave:20> A = cmat_2d(N_grids);
    
  6. The solution ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required