Good day guys. How do I write a Matlab program that will integrate a nonlinear system over one sample period?
조회 수: 1 (최근 30일)
이전 댓글 표시
I am trying to write a function that integrates a nonlinear model over one sample period. My outputs are next states (x1k1, x2k1). My inputs contain among others current states (x1k, x2k). I want to use the "int" command in matlab but, I am not getting it right. Below is my code.
function [x1k1,x2k1]=integr_S(x1k,x2k,uk,V,k1p,k2p,ca0,cb0,T)
% Calculates the next-state concentrations of the reactor given the
% input
syms ca0 x1k x2k k1p k2p cb0 uk V
fint1=(((ca0-x1k)*uk/V)-k1p*x1k);
fint2=(((cb0-x2k)*uk/V)-k2p*x2k);
x1k1=x1k+integral(fint1,t, 0, 1);
x2k1=x1k+integral(fint2,t 0, 1);
Please help.
Thanks
댓글 수: 11
Star Strider
2019년 3월 29일
Try this:
syms ca0 x1k x2k k1p k2p cb0 uk V t x1k(t) x2k(t)
fint1(t)=(((ca0-x1k(t))*uk/V)-k1p*x1k(t));
fint2(t)=(((cb0-x2k)*uk/V)-k2p*x2k(t)+k1p*x1k(t));
x1k1=x1k+int(fint1,t,0,1);
x2k1=x1k+int(fint2,t,0,1);
You need to define all the variables numerically to get a numeric result. Your numeric variables must either be defined after the syms call, or be omitted from the syms call.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!