Passing vector when using quad/integral
Show older comments
main function
N=5;
k=[-N:N];
f0=100;
fk=k*f0;
ak=coeff(k,f0)
at this stage, k is a vector with size of 1*11, it will be passed into coeff function.
sub-functions
function out=coeff(k,f0)
out=zeros(length(k),1);
for i=1:length(k)
out(i)=f0*quad(@(tt)integ(k(i),tt,f0),0,1/f0);
end
end
function out=integ(k,tt,f0)
xt=aux(tt);
for i=1:length(k)
out=xt.*exp(-j*2*pi*f0*k.*tt);
end
end
my objective is to not use the for loops in these sub-function. so is it possiable to pass the vector k into integ when using the quad?
Answers (0)
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!