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: John W. Eaton
Subject: Re: matlab to octave code errors
Date: Tue, 9 Jun 2009 15:01:51 -0400

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



reply via email to

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