I couldnt run function, I got error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

I couldnt run function, I got error

Aziz YÜCELEN

Hi

I am new for octave software. I wrote a function in a file (file name is try3.m ) and ran 


#  try3.m file

function find_point(x, modulo)
xeq1=(x^3)+x+1;
xeq2 = mod(xeq1,modulo);
  for i=0:(modulo-1)
      yeq1=(i^2);
     yeq2=mod(yeq1,modulo);
         if (xeq2==yeq2)
            printf("results:x= %d icin y=%d \n",x,i);
        endif
   endfor
endfunction
but I got this result:

>> try3

error: 'x' undefined near line 4 column 7
error: called from
    try3.m at line 4 column 5


what is wrong? And I want to call this function from cli but how?


Thanks.



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: I couldnt run function, I got error

Doug Stewart-4


On Wed, Feb 7, 2018 at 3:19 AM, Aziz YÜCELEN <[hidden email]> wrote:

Hi

I am new for octave software. I wrote a function in a file (file name is try3.m ) and ran 


#  try3.m file

function find_point(x, modulo)
xeq1=(x^3)+x+1;
xeq2 = mod(xeq1,modulo);
  for i=0:(modulo-1)
      yeq1=(i^2);
     yeq2=mod(yeq1,modulo);
         if (xeq2==yeq2)
            printf("results:x= %d icin y=%d \n",x,i);
        endif
   endfor
endfunction
but I got this result:

>> try3

error: 'x' undefined near line 4 column 7
error: called from
    try3.m at line 4 column 5


what is wrong? And I want to call this function from cli but how?


Thanks.


-----------------


from the cli try this

find_point(7,3)

--
DAS



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: I couldnt run function, I got error

Doug Stewart-4


On Wed, Feb 7, 2018 at 9:34 AM, Doug Stewart <[hidden email]> wrote:


On Wed, Feb 7, 2018 at 3:19 AM, Aziz YÜCELEN <[hidden email]> wrote:

Hi

I am new for octave software. I wrote a function in a file (file name is try3.m ) and ran 


#  try3.m file

function find_point(x, modulo)
xeq1=(x^3)+x+1;
xeq2 = mod(xeq1,modulo);
  for i=0:(modulo-1)
      yeq1=(i^2);
     yeq2=mod(yeq1,modulo);
         if (xeq2==yeq2)
            printf("results:x= %d icin y=%d \n",x,i);
        endif
   endfor
endfunction
but I got this result:

>> try3

error: 'x' undefined near line 4 column 7
error: called from
    try3.m at line 4 column 5


what is wrong? And I want to call this function from cli but how?


Thanks.


-----------------


from the cli try this

find_point(7,3)

--
DAS

I should have said:
try3(7,3)



--
DASCertificate for 206392



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------