How to use 'quad' function in Simulink
2 ビュー (過去 30 日間)
古いコメントを表示
I designed enthalpy calculation block in Simulink with MATLAB block.
Enthalpy is time-independent varibale.
but 'quad' function is not applicable in Simulink.
I want to know time-indepndent integral methode in Simulink.
y = quad('(28.9 - x.*0.1571e-2 + (x.^2).*0.8081e-5 - (x.^3).*2.873e-9 )/28.013',298, u);
0 件のコメント
採用された回答
Friedrich
2012 年 10 月 15 日
編集済み: Friedrich
2012 年 10 月 15 日
Hi,
this integral can be calaculted by hand pretty easily. So why not calaculate it by hand and putting the resulting formula into a MATLAB Function Block?
So the integral should be this:
- 2.563988148*10^(-11)*x^4 + 0.00000009615773629*x^3 - 0.0000280405526*x^2 + 1.03166387*x
So make a ML Function Block with your input u and use this formula to calculate the integral.
I created a small ML code which shows that both ways result in the same result and the approach "by brain" is a lot faster than the quad approach:
function test(u)
%used quad, use this in ML
tic
y = quad('(28.9 - x.*0.1571e-2 + (x.^2).*0.8081e-5 - (x.^3).*2.873e-9 )/28.013',298, u)
toc
%use this in a ML function block
tic
y = -2.563988148*10^(-11)*(u^4- 298^4) + 0.00000009615773629*(u^3 - 298^3) - 0.0000280405526*(u^2 - 298^2) + 1.03166387*(u - 298)
toc
E.g.:
>> test(300)
y =
2.0759
Elapsed time is 0.017596 seconds.
y =
2.0759
Elapsed time is 0.000374 seconds.
2 件のコメント
Walter Roberson
2012 年 10 月 15 日
-2.563988148*10^(-11)*(u-298)*(u-5029.38091682482)*(u^2+1577.06185213947*u+7.99648405441749*10^6)
Approximately. But only approximately, as you only use three significant digits to represent 28.9 so the formula should really only be calculating with three significant digits.
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!