Functions - How to use?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Let me begin by adding the disclaimer that I am very new to MATLAB. I downloaded a function from the file exchange, called 'power law, exponential and logarithmic fit' that I would like to use. However I am confused as to how to use a function like this after downloading it. It presents itself as an .m file, however when I open and run it, I receive an error that notifies me that x isn't defined. Yet when I attempt to define x I receive another error that states that 'function definitions are not permitted at the prompt or in the scripts'. If someone would please just push me in the right direction or offer me some literature that I can utilize to further my knowledge in this rather powerful program, I would greatly appreciate it. Thank you.
Answers (2)
bym
on 13 Aug 2011
0 votes
Oleg Komarov
on 13 Aug 2011
You have to put the .m file in a separate directory. I have a directiry called FEX.
Then you have to add that directory to the search path:
File > Seth Path > Add folder
After that you can call the function as you would do with any other one.
out = myFEXfunc(firstInput, another,...)
The correct syntax is usually indicated by the function's help:
help yourfunction
doc yourfunction
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!