Solving a State Space Model using Runge Kutta method, Mid Point or Heun Method to view system response

18 views (last 30 days)
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.

Answers (1)

Sam Chak
Sam Chak on 28 Oct 2022

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!