help-octave
[Top][All Lists]
Advanced

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

problem with m-file


From: Marco Hippler
Subject: problem with m-file
Date: Fri, 24 Nov 2006 14:43:58 +0100

Hi @ll
i've installed octave on my debian via aptitude.
Now my problem:
i've written an m-file test1.m

%m File
function summe=test1(A)
[m,n]=size(A);
summe=0;
for x=1:m
        for y=1:n
                summe=summe+A(x,y);
        end
end


than given A the values:

 A=[1 2;3 4]

and finally:

s=test1(A)

but it doesn't work:

error: complex scalar type invalid as index value
error: evaluating binary operator `+' near line 6, column 14
error: evaluating assignment expression near line 6, column 8
error: evaluating for command near line 5, column 2
error: evaluating for command near line 4, column 1
error: called from `test1' in file `/usr/share/octave/2.1.69/m/FH/test1.m'
error: evaluating assignment expression near line 16, column 2

let's have a look at the variables x&y
octave:16> x
error: `x' undefined near line 16 column 1
octave:16> y
error: `y' undefined near line 16 column 1
hmmm??????

then i've tried running it line by line in the promt and it works fine:

[m,n]=size(A)
m = 2
n = 2
summe = 0
octave:6> for x=1:m
> for y=1:n
> summe=summe+A(x,y)
> end
> end
summe = 1
summe = 3
summe = 6
summe = 10

so i think there's a basic problem with octave, does anybody have an idea?? (By 
the way, the m-file is from my professor and it works fine with Matlab in 
windows) :-(

_______________________________________________________________________
Viren-Scan für Ihren PC! Jetzt für jeden. Sofort, online und kostenlos.
Gleich testen! http://www.pc-sicherheit.web.de/freescan/?mc=022222




reply via email to

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