Issue with input arguements in a function

5 visualizaciones (últimos 30 días)
Carl
Carl el 13 de Sept. de 2011
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')

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Performance and Memory en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by