How to use 'quad' function in Simulink
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Friedrich
le 15 Oct 2012
Modifié(e) : Friedrich
le 15 Oct 2012
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 commentaires
Walter Roberson
le 15 Oct 2012
-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.
Plus de réponses (0)
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!