How do I perform this integration?
Show older comments
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);
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB Coder 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!