[Top][All Lists]

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

Re: Octave Error with Bounds

From: Doug Stewart
Subject: Re: Octave Error with Bounds
Date: Mon, 12 Dec 2016 06:56:22 -0500

On Mon, Dec 12, 2016 at 1:52 AM, darkstyle86 <address@hidden> wrote:
Good! When I add c(N)=0 to the code, the code progresses but the error changes to:

error: Project_solver_w_areas: A(I,J): row index out of bounds; value 41 out of bound 40
error: called from
    Project_solver_w_areas at line 71 column 13

I think it has to do with how I'm initializing the temperatures values in T(i,j) under "Initialization of temperatures using 1-D analytical solution".  But it's a similar problem with bounds.  Any ideas here?  I tried adding a(1)=0 to the code and that didn't help.  Thank you.

From: Doug Stewart-4 [via Octave] <>
Sent: Friday, December 9, 2016 10:26 PM
To: darkstyle86
Subject: Re: Octave Error with Bounds

On Fri, Dec 9, 2016 at 8:24 PM, darkstyle86 <[hidden email]</user/SendEmail.jtp?type=node&node=4680990&i=0>> wrote:
Hello, there may be a post that helps me with my exact problem but I haven't
found it yet, so please direct me to that post if you know of it.  Thank
you.  I'm putting a code together to determine the 2-D temperature
distribution in a triangular fin.

My base code is as follows:

M=41; % number of grid points in x-direction
N=31; % number of grid points in y-direction
dx=w/(M-1); % delta x
dy=L/(N-1); % delta y
for i=1:M x(i)=dx*i; end
for j=1:N y(i)=dy*j; end

% Initialization of temperatures using 1-D analytical solution
for j=1:N
    for i=2:(M-1) T(i,j)=Tinf; end

change   this
 for i=2:(M-1) T(i,j)=Tinf; end
 for i=2:(M) T(i,j)=Tinf; end

for iter=1:10
    % forward sweep
    for i=2:(M-1)

        for j=2:(N-1)





you should have a c(N)= something here.

        for j=1:N T(i,j)=Ttemp(j); end

The function TDMAsolver I am using is the following code:

function x = TDMAsolver(a,b,c,d)
%a, b, c are the column vectors for the compressed tridiagonal matrix, d is
the right vector
n = length(b); % n is the number of rows.  The first row is i=1.

% Modify the first-row coefficients
c(1) = c(1) / b(1);    % Division by zero risk.
d(1) = d(1) / b(1);    % Division by zero would imply a singular matrix.

for i = 2:n
    id = 1 / (b(i) - c(i-1) * a(i));  % Division by zero risk.
    c(i) = c(i)* id;                % Last value calculated is redundant.
    d(i) = (d(i) - d(i-1) * a(i)) * id;

% Now back substitute.
x(n) = d(n);
for i = n-1:-1:1
    x(i) = d(i) - c(i) * x(i + 1);

The error I'm getting when I run my base code is:

"error: TDMAsolver: A(I): index out of bounds; value 31 out of bound 30
error: called from
    TDMAsolver at line 11 column 10
    Project_solver_w_areas at line 80 column 14"

I can't figure out what the problem is.  Does anyone have any ideas?  Thank

View this message in context:
Sent from the Octave - General mailing list archive at

Help-octave mailing list
[hidden email]</user/SendEmail.jtp?type=node&node=4680990&i=1>

DAS[Certificate for 206392]


Help-octave mailing list
[hidden email]</user/SendEmail.jtp?type=node&node=4680990&i=2>

If you reply to this email, your message will be added to the discussion below:
To unsubscribe from Octave Error with Bounds, click here<>.

View this message in context:
Sent from the Octave - General mailing list archive at

Help-octave mailing list

DASCertificate for 206392

reply via email to

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