Good day guys. How do I write a Matlab program that will integrate a nonlinear system over one sample period?

2 次查看(过去 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
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.
For an extended discussion of symbolic variables, see: Symbolic Computations in MATLAB (link).

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by