help-octave
[Top][All Lists]
Advanced

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

Re: matlab to octave code errors


From: Adam Spontarelli
Subject: Re: matlab to octave code errors
Date: Wed, 10 Jun 2009 08:39:06 -0400

Sorry I did not include bandsol.m . I obviously did not write this code, it was provided in a textbook that i'm trying to use for a project. I ran the program with your changes and it worked, but the answers came out as "NaN" which is junk. Are you certain that the change you made didn't affect the logic?

Thank you.

On Tue, Jun 9, 2009 at 15:01, John W. Eaton <address@hidden> wrote:
On  9-Jun-2009, Adam Spontarelli wrote:

| I apologize, you were right about the input file having a problem. This is
| the correct .inp file that works in MatLab, however, it still gives me
| trouble in octave. After applying your fix to line 54, I now get:
|
| error: invalid vector index = 0
|
| error: evaluating binary operator `-' near line 144, column 16
|
| error: evaluating assignment _expression_ near line 144, column 8
|
| error: evaluating for command near line 140, column 1

There are other places where you need a similar change.  Also, some
might not be obvious, or detected in the same as the first.  For
example, once N is defined on line 54, the _expression_ on lines 63 and
64:

  [N,NOC(N,:), MAT(N,:), AREA(N,:), DT(N,:)] = ...

     deal(TMP(1),TMP(2:1+NEN), TMP(2+NEN), TMP(3+NEN), TMP(4+NEN));


will probably not do what you expect.

In any case, it seems to me that all the uses of deal in your file are
somewhat questionable.  I see no good reason to write the above with a
call to deal.  Instead, I would recommend writing this _expression_ as
the series of assignments

 N = TMP(1);
 NOC(N,:) = TMP(2:1+NEN);
 MAT(N,:) = TMP(2+NEN);
 AREA(N,:) = TMP(3+NEN);
 DT(N,:) = TMP(4+NEN);

After I made changes like this, your example worked up to the point of
calling the function "bansol", which you did not provide and which is
not part of Octave (or Matlab, as far as I can tell).

jwe

Attachment: bansol.m
Description: Binary data


reply via email to

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