Good day guys. How do I write a Matlab program that will integrate a nonlinear system over one sample period?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Star Strider
il 29 Mar 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.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Calculus in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!