フィルターのクリア

Integration using quad(@myfun,a,b)

3 ビュー (過去 30 日間)
Amy
Amy 2014 年 4 月 4 日
コメント済み: Star Strider 2014 年 4 月 5 日
I have the following function
function AW1= AW_int()
ASqr=aSqrSum();
BSqr=bSqrSum();
C=CSum();
delta2=(ASqr.*BSqr)-(C.^2);
delta=delta2.^(1/2);
AW1=delta./ASqr;
format long e
delta2;
delta;
%delta2; delta;
AW1;
end
Using the following functions for ASqr, BSqr and C
function ASqr =aSqrSum(x,N)
N=[1000 10000 100000];
x=[0.9 0.99 0.999 0.9999];
ASqr = zeros(length(N), length(x));
for ii = 1:length(N)
for n = 0:N(ii)-1
ASqr(ii,:) = ASqr(ii,:) + (x.^(2*n));
end
end
function C = CSum(x,N)
N=[1000 10000 100000];
x=[0.9 0.99 0.999 0.9999];
C = zeros(length(N), length(x));
for ii = 1:length(N)
for n = 0:N(ii)-1
C(ii,:) = C(ii,:) + (n.*x.^(2.*(n)-1)) ;
end
end
format long e
C;
end
format long e
ASqr;
end
function BSqr =bSqrSum(x,N)
N=[1000 10000 100000];
x=[0.9 0.99 0.999 0.9999];
BSqr = zeros(length(N), length(x));
for ii = 1:length(N)
for n = 0:N(ii)-1
BSqr(ii,:) = BSqr(ii,:) + ((n.^2).*x.^(2.*(n)-2));
end
end
format long e
BSqr;
end
When i try to integrate the function AW_int using
Q = quad(@AW_int,0,0.9999)
The following error is returned:
Error using AW_int
Too many input arguments.
Error in quad (line 72)
y = f(x, varargin{:});
Would anyone be able to help me fix this? As I have tried a few different things but the same error is still be returned.
Thanks

採用された回答

Star Strider
Star Strider 2014 年 4 月 4 日
Your AW_int function doesn’t take any input arguments:
function AW1= AW_int()
Also, you are not passing any arguments to these functions within AW_int, so they will likely throw a similar error when AW_int executes:
ASqr=aSqrSum();
BSqr=bSqrSum();
C=CSum();
They all require x and N as inputs, so pass those to AW_int and then to the other functions.
  14 件のコメント
Amy
Amy 2014 年 4 月 5 日
Sorry.. hope this helps
Star Strider
Star Strider 2014 年 4 月 5 日
Definitely helps, but I’m a bit baffled by the implied recursion. You calculate
∆² = A²B²-C²
all of which are functions of x, and with
A² = ∑x²ʲ
then go back and integrate ∆/A² w.r.t. x.
Also, when I calculate (with EN the asymptotic expression), I get:
Q/(EN*pi) = 1.2031 1.3860 1.2943
perhaps accounted for by σ² not appearing anywhere, but just a guess on my part.
If there’s no recursion, and you treat ∆/A² essentially as a constant, then you pretty much have calculated Q about as well as can be expected, except for dividing it by pi. I am not convinced that using continuous functions and integrate would be of any significant benefit.
If there is recursion, then it seems to me you carry out the summations and calculate ∆/A² for each x(j), integrate from a to b, and repeat until you reach j=(n-1). Maybe I’m missing something.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by