MATLAB: Can I pass the model name into the ([],[],[],’compile’) command

MATLABsimulink

for example, it at first works with f14([],[],[],'compile'); But now i want to write this command into a function, and i want to do something like this: function compile(MyModel) MyModel([],[],[],'compile');
————– And MyModel is some name i will pass in. When i try to do this it prompt some error to me. "??? Index exceeds matrix dimensions." Why?
Thank you very much.

Best Answer

Try:
function compile(MyModel)
eval([MyModel '([],[],[],''compile'')']);