Info
This question is closed. Reopen it to edit or answer.
How do I pass a function handle to a function I created? Error: Undefined function 'SpecAnl' for input arguments of type 'function_handle'
1 view (last 30 days)
Show older comments
I have created a function 'SpecAnl' and want to pass a function handle to one of its variables. My anonymous function is defined:
func=@(t) 1+cos(pi*t)+2*sin(2*pi*t);
and my function 'SpecAnl' is written:
function [a,b]=SpecAnl(x,T,dt,h)
c=zeros(h+1,1);
a1=0;
t0=0;
for k=1:(h+1)
for n=1:ceil(T/dt)
a1= a1 + dt/T*x(t0)*exp(-2j*pi*k*t0/T);
t0= t0 + dt;
if n==floor(T/dt)
a2=a1;
end
c(k)=(a1+a2)/2;
end
a=2*real(c);
b=-2*imag(c);
My function is saved in the main path. When I call
SpecAnl(func,...
from the command window, I get the following message:
Undefined function 'SpecAnl' for input arguments of type 'function_handle'.
0 Comments
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!