Did you check what you get for f?
f21=@(x)(exp(-x/3))/(4-cos(pi*x));
This returns a scalar, so f will be of size 1*1. If you want element-wise division, then this will not fail:
f21=@(x)(exp(-x/3))./(4-cos(pi*x));
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!