This MATLAB tutorial video will show you how to make subfunctions in MATLAB. This allows you to have functions that are available only to other functions in the same file. This is ideal when you have subroutines that are only likely to be useful to the other functions in that file.
3 CommentsOldest to Newest
function approx = taylorSine(x) numTerms = 4; term = 1 : numTerms; n = term*2 - 1; correction = x.^n ./ factorial(n); oddsign = (-1).^(1+term); approx = sum(oddsign.*correction);(Of course I just bypassed the whole point of the video... oops. I originally replaced it with an anonymous function isOdd = @(x) mod(x,2); Is there a support group called Functions Anonymous?) (testing, ignore this: isOdd = @(x) mod(x,2);, this concludes the test of the comment system.)