How do I perform this integration?
1 view (last 30 days)
Show older comments
Dipankar Narayanan
on 3 Mar 2015
Commented: Dipankar Narayanan
on 3 Mar 2015
H=[11 22 33 44 55 66];
R=[1 2 3 4 5];
f_low=[1000 3000 5000 7000 9000];
f_high=[2000 4000 6000 8000 10000];
Const=5;
RESULTS=[];
for i=1:length(H)
val=quadgk(@(f)MyFunction(f,H,R,Const),f_low(i),f_high(i));
RESULTS=[RESULTS val];
end
+++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++
function int_out=MyFunction(f,H,R,Const)
AAA=Const+2.*sum(H.*cos(2*pi*f*R));
int_out=AAA.^2;
+++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++
I get the following Error:
Error using * Inner matrix dimensions must agree.
Error in MyFunction (line 3) AAA=Const+2.*sum(H.*cos(2*pi*f*R));
Error in @(f)MyFunction(f,H,R,Const)
Error in quadgk/evalFun (line 330) fx = FUN(x);
Error in quadgk/f1 (line 348) [y,too_close] = evalFun(tt);
Error in quadgk/vadapt (line 249) [fx,too_close] = f(x);
Error in quadgk (line 188) [q,errbnd] = vadapt(@f1,interval);
0 Comments
Accepted Answer
Torsten
on 3 Mar 2015
I'd do the integration by taking pencil and paper:
The antiderivative of a*cos(2*pi*x*R) is a/(2*pi*R)*sin(2*pi*x*R).
Best wishes
Torsten.
More Answers (0)
See Also
Categories
Find more on Analog Filters 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!