help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Octave forge] [bim package]


From: c.
Subject: Re: [Octave forge] [bim package]
Date: Sun, 4 Feb 2018 17:58:35 +0100


> On 4 Feb 2018, at 17:55, c. <address@hidden> wrote:
> 
> This code snippet for example:
> 
>>> pkg load bim
>>> x = [linspace(0, .5, 100), linspace(.5, 1, 200)(2:end)].';
>>> A = bim1a_laplacian (x, 1, 1);
>>> b = bim1a_rhs (x, 1, 1);
>>> u = zeros (size (x));
>>> u(2:end-1) = A(2:end-1, 2:end-1) \ b(2:end-1);
>>> plot (x, u, 'x-')
> 
> solves 
> 
> - u''(x) = 1    in 0 < x < 1
> u(0) = u(1) = 0
> 
> on a piece-wise uniform mesh.

And, to try a more complex non-uniform mesh spacing, you could test this:

>> y = x .^ 3;
>> A = bim1a_laplacian (y, 1, 1);
>> b = bim1a_rhs (y, 1, 1);
>> u = zeros (size (y));
>> u(2:end-1) = A(2:end-1, 2:end-1) \ b(2:end-1);
>> plot (y, u, 'x-')

c.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]