Steps from Mupad to custom Matlab M function
Here are the steps involved to create an M function from a Mupad session:
(This uses calculating the basis used in futures trading of Cash Price – Future Price)
>> notebook_handle = mupad;
>> basis = getVar(notebook_handle,’basis’) <–note: do keep Mupad open in order for this to work!!
FC – FP
>> h = matlabFunction(S)
Undefined function or variable ‘S’.
>> h = matlabFunction(basis)
>> basis = matlabFunction(basis,’file’, ‘basis.m’);
Here is the resulting M function basis.m:
function basis = basis(FC,FP)
% BASIS = BASIS(FC,FP)
% This function was generated by the Symbolic Math Toolbox version 6.2.
% 26-Jul-2015 21:13:44
basis = FC-FP;
NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!