freemat errors when reading the function definitions

1,306 views
Skip to first unread message

Emil Brodt

unread,
Jul 17, 2014, 11:00:54 AM7/17/14
to fre...@googlegroups.com
I've installed the freemat and started to learn it.
I'm trying to repeat the sample from the documentation.
I copied from the GreeMat-4.2.pdf the following sample

function c = addtest(a,b)

c = a + 2*b;


When running the script I get the error


Error: only scripts can be source-ed, not functions


When I run the same text from another script I get the error


Error: Function definition unexpected!

--> Error: Undefined function or variable a


Why the different reaction from the different *.m scripts ?

They are in the same location.


Why the errors ?




biplab mukherjee

unread,
Jul 19, 2014, 2:48:54 PM7/19/14
to fre...@googlegroups.com
You have to name the .m file the same name as the function name, like your function name is 'addtest'
so you should save the file in the same name like 'addtest.m'    
change your directory to the path you have saved the m file and then run it .

Emil Brodt

unread,
Jul 24, 2014, 5:11:32 AM7/24/14
to fre...@googlegroups.com

Dear biplab mukherjee
When running the script addtest.m having the text

       function c = addtest(a,b)

c = a + 2*b;

 

 

I get the message

Error: only scripts can be source-ed, not functions

 
 
Why it can be ?
 
 
Reply all
Reply to author
Forward
0 new messages