Include compose functions


Answers
-
Hello Matthieu,
You can call the function using function name along with input arguments.
I have the following function (test) which does the addition of two input numbers.
function out = test(a,b)
out = a+b;
end
Way of calling the function:
test(1,3)
out = test(1,3)
0 -
Hi,
This works if both are in the same file. I was referring to the function being in one file and the call in a different one. How can I include the first file in the second one?
Thanks,
Matthieu
0 -
Hi Matthieu,
1st we need to save the function script with the same name and use the function name in a different file.
say for example
script 1: save the test function as test.oml
function out = test(a,b)
out = a+b;
end
then,
you can call the 'test' in a different file as a script/function:
function val = test2()
a = 5
b =6
out = test(a,b)
val = out;
end
hope this helps.
Thanks,
Manoj kandukuri
0 -
Please mind that the file should be either:
- added to 'path' by calling addpath('<pathtotestoml>); however this will affect only the current Compose session (closing and reopening Compose will reset path to its original value)
- reside in the same folder of the calling function.
Otherwise the test function that you saved in test.oml won't be found.
0