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!