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

1 Ansicht (letzte 30 Tage)
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 Kommentare
Star Strider
Star Strider am 29 Mär. 2019
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).

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by