Issue with input arguements in a function
Show older comments
No matter how I change the function highlighted at the bottom I cannot get rid of the error: ??? Error using ==>@(f,t,n) Too many input arguments. I have read through Mathworks help description and examples of function arguments and I do not see a error in this function. Any help on this would be greatly appreciated.
syms t k n
evalin(symengine,'assume(k,Type::Integer)');
f = @(t)evalin(symengine,['subs(piecewise([0 <= t and t < 2,',...
'sin((Pi*t^2)/4)],[t <= 2 and t < 3, 5*t-t^2-6], [t <=3 and t < 4, 0],',...
'[Otherwise, t-4]),t=',regexprep(mat2str(x),' ',','),')']);
a = @(f,t,k) int(f*cos(k*pi*t/4)/4,t,-2,8);
b = @(f,t,k) int(f*sin(k*pi*t/4)/4,t,-2,8);
ERROR OCCURS HERE
fs = @(f,t,n) a(f,t,0)/4 + ...
symsum(a(f,t,k)*cos(k*pi*t/4) + b(f,t,k)*sin(k*pi*t/4),k,1,n);
g = fs;
pretty(fs(g,t,25,1))
ezplot(fs(g,t,25,1),-2,8)
hold on
ezplot(f,-2,8)
hold off
title('Partial sum with n=25')
Accepted Answer
More Answers (0)
Categories
Find more on Performance and Memory in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!