help-octave
[Top][All Lists]
Advanced

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

Re: declare global as matrix...problem to use it


From: Doug Stewart
Subject: Re: declare global as matrix...problem to use it
Date: Tue, 3 Jul 2018 11:04:28 -0400



On Tue, Jul 3, 2018 at 10:44 AM, turbofib <address@hidden> wrote:
hi doug,

i try it :


Main.m:

global a;

a=[1 12 30;3 5 50;6 3 2]


*******************
function ret = eserciziGlobal_Funzioni(x)

 global a;

   ret=a;

endfunction

*****************
Here..i call function:

>> eserciziGlobal_Funzioni(3)

i receive the error:

error: 'a' undefined near line 6 column 8
error: called from
    eserciziGlobal_Funzioni at line 6 column 7


if you make one file with this in it:

function ret = eserciziGlobal_Funzioni(x)
 global a; 
   ret=a;
endfunction

and name it  eserciziGlobal_Funzioni.m


and a second file with this in it


global a;
a=[1 12 30;3 5 50;6 3 2]
eserciziGlobal_Funzioni(3)

and name it testglobal.m

and then at the command prompt type

testglobal

It works for me.



--
DAS


reply via email to

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