Solving a State Space Model using Runge Kutta method, Mid Point or Heun Method to view system response
18 views (last 30 days)
Show older comments
Hi,
I was designing a project where I want to develp a function [y,t] =step_response(Gs,method) that can solve a state space model for system responce. The function would accept Transfer function and the method to be used,converts the tf into state space representation
My state space equation looks like
dx(t) = Ax(t) + Bu(t)
y(t) = Cx(t) + Du(t)
{The result will be ploted similearly to what we get from using step(sys) where sys = ss(A,B,C,D) } I need to impliment this function using 4th order Runge Kutta, Mid Point or Heun Method.
Im taking
h = 0.1; %so the results becomes obvious
u = 1; %As Im trying to replicate the step() function
Using Stepinfo to determine the time vector
SS = stepinfo(sys);
Tf = SS.SettlingTime %Should i be using the stettling time?
To = 0; %Starting time
I dont want the complete solution Just the start, how should i make a function f() which i will use
I got this from online searching and for my case should u be constant if so then what is this I and how to get x0

I am thinking once i get all x(i) ill be able to use them in y(t) = C*x(t) + D*u(t) to get the system responce.
All help is appriciated, and sorry for my lackings.
1 Comment
Benjamin Pommer
on 28 Feb 2023
I dont know if that problem has already been solved but dont include B and u here.
Answers (1)
Sam Chak
on 28 Oct 2022
Hi @Anas Rehman
If you still keep the old versions of MATLAB (R2012 and older), you can find the requested ODE solvers in the library. Else, get them here:
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!