How to use 'quad' function in Simulink

조회 수: 2 (최근 30일)
Taehong
Taehong 2012년 10월 15일
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);

채택된 답변

Friedrich
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
Taehong
Taehong 2012년 10월 15일
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 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개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by