フィルターのクリア

Integration of MATLAB function - NOT Mathematic function.

3 ビュー (過去 30 日間)
Echo-6
Echo-6 2016 年 9 月 2 日
コメント済み: Walter Roberson 2016 年 9 月 3 日
Hi, I have three MATLAB script, with one serve as a main class. I want to integrate an expression which contain two other functions,
Code:
x = 0:180;
TB = integral(getCt_Theta(x)*getQ_2(x),1,180);
Where: getCt_Theta(x), is a function to calculate coefficient of lift, will return one values for each inputs Same goes for getQ_2(x), The reason for this task is to evaluate half revolution of the turbine. Should I do symbolic first? or should I Simulink it?
Thanks everyone!
  2 件のコメント
Walter Roberson
Walter Roberson 2016 年 9 月 2 日
Your x is the integral values from 0 to 180, but you mention x in your integral() and you want the integral to be over 1 to 180. Is your x intended to be continuous or discrete, and is it intended to be 0 to 180 or 1 to 180 ?
Echo-6
Echo-6 2016 年 9 月 3 日
編集済み: Echo-6 2016 年 9 月 3 日
Hi Walter, My bad, I intent to integrate from 0-180. The raw data one of the function access to is from a CSV file, interpolated. So it's continuous.

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

採用された回答

Walter Roberson
Walter Roberson 2016 年 9 月 3 日
f = @(x) getCt_Theta(x).*getQ_2(x)
and integral that:
integral(f, 0, 180)
However, this depends upon getCt_Theta and getQ_2 accepting vectors of values. If they cannot, if they can only accept scalars, then you need
integral( @(X) arrayfun( f, X), 0, 180)
  1 件のコメント
Echo-6
Echo-6 2016 年 9 月 3 日
Awesome man! Now I got the integration result! Thanks!

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

その他の回答 (1 件)

Pawel Ladosz
Pawel Ladosz 2016 年 9 月 2 日
You could try and change your matlab function to function handle by:
getCt_Theta_fun=@getCt_Theta
Then you can use this is as input to integral. However I am not sure whether it would deal with multiplication of the function handles.
  3 件のコメント
Echo-6
Echo-6 2016 年 9 月 3 日
編集済み: Walter Roberson 2016 年 9 月 3 日
Dear Adam, I have try the function handle by using only getQ_2 first. Just to prove the concept. The function is valid from 0-180, I have check it.
Code I try
f = @(theta) getQ_2;
TB = integral(f,1,180);
I got the following error-
Not enough input arguments.
Error in getQ_2 (line 2)
theta= deg2rad(theta);
Error in Int_test_1>@(theta)getQ_2
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in Int_test_1 (line 5)
TB = integral(f,1,180);
Any ideas? And Thanks everyone!
Walter Roberson
Walter Roberson 2016 年 9 月 3 日
f = @(theta) getQ_2(theta);

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

カテゴリ

Help Center および File ExchangeWind Power についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by