You also can call the live function from a live script. For example, create a live script
called mystats.mlx. Add this code that declares an array, determines the length of the
array, and passes both values to the function mymean.
x = 1:10;
n = length(x);
avg = mymean(x,n);
disp(['Average = ', num2str(avg)])
Run the live script. The Live Editor displays the output.
If a live function displays text or returns values, the Live Editor displays the output in the
calling live script, in line with the call to the live function. For example, add a line to
mymean that displays the calculated mean before returning the value:
function a = mymean(v,n)
a = sum(v)/n;
disp(['a = ', num2str(a)])
end
When you run mystats, the Live Editor displays the output for mymean with the output
from mystats.
Create Live Functions