How to use 'quad' function in Simulink

12 Ansichten (letzte 30 Tage)
Taehong
Taehong am 15 Okt. 2012
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);

Akzeptierte Antwort

Friedrich
Friedrich am 15 Okt. 2012
Bearbeitet: Friedrich am 15 Okt. 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 Kommentare
Taehong
Taehong am 15 Okt. 2012
Thank you.
I'm totaly forgot what I did in my work.
Your insight totally rescue my hoplessenss.
Thank you again.
Walter Roberson
Walter Roberson am 15 Okt. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by