Say I had the following code:
% Cellmode_subfunction_test.m
%% Cell 1
foo(1);
%% Cell 2
foo(2);
%% Definition of the foo subfunction
function foo(num)
disp(['num=' num2str(num)]);
How can test cell 1 and cell 2 with the subfunction defined at the end?
Edit: Basically each of the cells in this example perform some lengthy calculations so I'd like to test and debug them separately. I'm using subfunctions to abstract out and reuse common functionality and since so far this functionality is only used in this particular application I don't really want to place foo in a separate m-file.
Edit(2): I just remembered that I vaguely recall cell mode only working in matlab scripts and not in function m-files and that subfunctions and nested functions are not allowed in such scripts. Thus what I'm asking for is probably not possible.
Although the anonymous function solution given below is perhaps somewhat restrictive as it only allows single expression functions, it did in fact suffice for what I wished to do and hence I've accepted it as a solution to my problem.