I have the following transfer function that I am trying to model in MATLAB with some additional unity white noise:
$$G(s)=\frac{1}{s^3 + \beta s^2}$$
I used the following to obtain the continuous state space equation:
beta = 0.2;
b = [0 0 0 1];
a = [1 beta 0 0];
[A,B,C,D] = tf2ss(b,a);
My understanding is that the tf2ss()
function provides me with the values A and B which can be used in the following equation:
dxdt = Ax + Bu, where x is the initial condition and u is the unity white noise.
Upon running the above code snippet, I obtain the following values for A and B:
A = [-0.2,0,0; 1,0,0; 0,1,0]
B = [1; 0; 0]
Here is where I am running into trouble (although I may have run into an issue before with my assumptions regarding tf2ss()
). I do not understand how to write the differential equation function required to use ode45()
. I have tried the following:
function dx = mydiffeq(t,x)
A = [-0.2,0,0;1,0,0;0,1,0];
B = [1;0;0];
dx = A*x + B*randn(1);
end
And then I call it as follows:
tspan = [0 10];
xnot = 100;
[t,y] = ode45(@mydiffeq, tspan, xnot);
plot(t,y);
Obviously, I have a problem due to the size of my A and B matrices. I know that I am doing this wrong, but I do not know how to fix it.