1

I tried to use a private MATLAB function (private means that I wrote it myself) via the matlabbatch object in SPM12 that I compiled :

run_spm12.sh $MCR_ENV run batch.m

with the batch.m file containing the following lines:

matlabbatch{1}.cfg_basicio.run_ops.call_matlab.inputs{1}.string = 'Hello world';
matlabbatch{1}.cfg_basicio.run_ops.call_matlab.outputs = {};
matlabbatch{1}.cfg_basicio.run_ops.call_matlab.fun = 'myfunction';

with the function 'myfunction' defined in the file myfunction.m as:

function myfunction(n)
disp(n);
end

The error message returned by SPM is the following:

Item 'Function to be called', field 'val': Item must be a function handle or function name.

However, it works if i replace the function 'myfunction' by a standard MATLAB function, such as 'disp' for instance. It suggests that, somehow, I need to specify the path to the myfunction.m file but I did not find out how.

Thanks for your help.

Dan
  • 12,157
  • 12
  • 50
  • 84
Yakko-San
  • 11
  • 1
  • 1
    Where does `myfunction.m` live on your system? Is it on your path? – Suever Apr 11 '16 at 14:39
  • @Suever: the file myfunction.m was added to mcc via the '-a' option while it should have been with the '-I' option. Problem solved. Thank you for your help. – Yakko-San Apr 21 '16 at 07:46

0 Answers0