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 11:08:10 -0400

On  9-Jun-2009, smed wrote:

| Ivan Sutoris wrote:
| > 
| > Hi
| > 
| > If it works in Matlab, then probably the "deal" function works
| > differently in Octave. You can try to rewrite line 54 in two separate
| > lines (though I didn't test it, as your program requires additional
| > input files):
| > 
| > % [N, X(N,:)]=deal(TMP(1),TMP(2:1+NDIM));
| > N = TMP(1);
| > X(N,:) = TMP(2:1+NDIM);

It's not a problem with deal, but with the way multi-assignments are
handled.  Apparently Matlab is creating the variable N before
evaluating the second element in the assignment and Octave is not.
This problem should probably be fixed, but as Ivan notes, you can
easily work around it yourself by using a temporary variable.

| Thank you for your response. I tried your suggestion, but i'm still getting
| errors.
| 
| warning: function name `fem1d2n' does not agree with function file name
| `C:\Matlab\fem1d.m'
| 
| error: invalid matrix index = 1
| error: evaluating argument list element number 1
| error: evaluating for command near line 79, column 1
| error: called from `fem1d:InputData' in file `C:\Matlab\fem1d.m'
| error: called from `fem1d' in file `C:\Matlab\fem1d.m'
| 
| http://www.nabble.com/file/p23941353/FEM1D.INP FEM1D.INP 
| 
| Here is the input file I'm using, and yes it works in matlab. Thanks again. 

OK, this problem seems to be happening here:

  DUMMY = fgets(LINP)
  F = zeros(NN,1);
  for I=1:NL
     TMP = str2num(fgets(LINP));
     [N,tmp]=deal(TMP(1),TMP(2));
     F(N) = tmp;
  end

when indexing TMP in the call to deal.  If I look at the value of TMP,
it is [], because fgets(LINP) is returning "DOF#  Load".  Are you sure
FEM1D.INP is a valid input file for your program?  It seems that ND is
1, but there are 4 lines of displacements.  Is that correct?

jwe



reply via email to

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