help-octave
[Top][All Lists]
Advanced

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

Re: using scope variable in function


From: James Sherman Jr.
Subject: Re: using scope variable in function
Date: Sun, 14 Jun 2009 14:07:08 -0400

The two solutions that I would do are either:

1) pass the variable Ascan to the function, like:
function G = test1(n, Ascan)
<the rest of your function>

then, just call the function like:

load yourmatfile.mat
G = test1(n, Ascan)

or

2) load the mat file inside the function
function G = test1(n);
load yourmatfile.mat
s=Ascan(n,n+1);
G=s;
endfunction;

On Sun, Jun 14, 2009 at 11:37 AM, Huub van Niekerk <address@hidden> wrote:
Hi,

Using Octave 3.2.0 on MacOSX 10.5, I'm writing a function in which I want to use the variable Ascan that comes from a mat file I loaded:



function G = test1(n);
> s=Ascan(n,n+1);
> G=s;
> endfunction;
octave-3.2.0:10> test1(1)
error: `Ascan' undefined near line 2 column 3
error: called from:
error:   test1 at line 2, column 2


_______________________________________________
Help-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave



reply via email to

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