help-octave
[Top][All Lists]
Advanced

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

Re: Functions in Octave


From: Fausto Arinos de A. Barbuto
Subject: Re: Functions in Octave
Date: Thu, 27 Aug 2015 18:02:56 +0000 (UTC)


Hi James,

As I wrote, Source2.m was ported from Matlab and I obviously had to
adequate it to Octave. Then several "end" commands in the original
Matlab code were replaced by "endfunction", "endfor" and "endif"
whenever and wherever required. But that was it. The logic of both
Matlab and Octave scripts is the very same however.

As expected, Source2.m works if I write BporLinhas.m and BporColunas.m
as separate files. But I don't want that. I want the functions to sit
inside Source2.m so that they can be readily visible/editable.

Lastly, the big question: testefun.m works and I hadn't to write its
two functions as separate files. Why?

Thanks for your reply.

Fausto




On Thursday, August 27, 2015 2:27 PM, James Sherman Jr. <address@hidden> wrote:


On Thu, Aug 27, 2015 at 12:58 PM, fbarbuto <address@hidden> wrote:
> The way Octave works puzzles me sometimes.
>
> The very simple, proof-of-concept testfun.m calls two functions and it
> works.
>
> Source2.m also calls two functions, but doesn't work. I get the following
> error message:
>
> *error: 'BporLinhas' undefined near line 54 column 20
> error: called from
>    Source2 at line 54 column 18
> *
> The more I examine their structures, the less I understand why one code runs
> fine whereas the other doesn't.
>
> Source2.m was ported from Matlab, where it /does/ work.
>
> What's the problem?
>
> Fausto
>
> testefun.m <http://octave.1599824.n4.nabble.com/file/n4672321/testefun.m>
>
> Source2.m <http://octave.1599824.n4.nabble.com/file/n4672321/Source2.m>
>
>
>
> --
> View this message in context: http://octave.1599824.n4.nabble.com/Functions-in-Octave-tp4672321.html
> Sent from the Octave - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-octave

I just tried your Source2.m file in Matlab, and I got the following error:

>> source2
Error: File: source2.m Line: 87 Column: 1
Function definition is misplaced or improperly nested.

Which I expected, since I didn't think that Matlab supported multiple
function definitions in the same file.  Are you sure that your
Source2.m, as written, works in Matlab?  If you write each of your
functions in separate files named BporLinhas.m and BporColunas.m and
then run your Source2.m function (in Octave), what happens then?  Make
sure that either your current directory is the same directory as the
three files, or that the path contains that directory.

Hope this helps,

James Sherman



reply via email to

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