Issue with input arguements in a function

5 views (last 30 days)
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

Walter Roberson
Walter Roberson on 13 Sep 2011
Urrr -- you are aware that just 2 and 3 lines down, you call fs with four arguments instead of 3 ??
  1 Comment
Carl
Carl on 13 Sep 2011
Crap. Always the most obvious things that are overlooked.

Sign in to comment.

More Answers (0)

Categories

Find more on Performance and Memory in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!