Till now my MATLAB Snippet has been functioning well until I recently defining a function in the script editor. For e.g.
% In the script editor inside the MATLAB Snippet configuration window
kIn_cell = dataset2cell(kIn);
% some code here
kIn_cell_new = add_cell(kIn_cell);
% Defining the function
function kIn_cell_new = add_cell(kIn_cell)
% Code defining the function
When I run the code, I received the error of "Function definition is misplaced or improperly nested.". After I open the temporary .m file, I found out that the snippet is using a try/catch statement, and my own function is not allowed to be defined inside this control statement as a nested function.
How do I solve this problem? Is there anyway I can define my functions elsewhere? I urgently need a solution, thanks!