transform this equations into state space model: dx1(t)/dt = x1(t)-u(t) dx2(t)/dt = x1(t) - x2(t) in matlab

We can write the system of equations in matrix form as follows:

main.m
dx(t)/dt = Ax(t) + Bu(t)
y(t) = Cx(t) + Du(t)
46 chars
3 lines

where x(t) is the state vector, u(t) is the input vector, y(t) is the output vector, and A, B, C, and D are matrices that define the system.

For the given equations, we have:

main.m
x1_dot = x1 - u
x2_dot = x1 - x2
33 chars
3 lines

We can define the state vector as x = [x1; x2]. Then, we can write the equations in matrix form as follows:

main.m
x_dot = [x1_dot; x2_dot] = [x1 - u; x1 - x2] = [1 -1; 1 -1] * [x1; x2] + [1; 0] * u
y = x = [1 0] * [x1; x2]
109 chars
3 lines

Therefore, the state-space model in Matlab can be written as:

main.m
A = [1 -1; 1 -1];
B = [1; 0];
C = [1 0];
D = 0;

sys = ss(A, B, C, D);
71 chars
7 lines

Finally, we can use the ss2tf function to convert the state-space model to a transfer function:

main.m
[num, den] = ss2tf(A, B, C, D);
tf_sys = tf(num, den);
55 chars
3 lines

related categories

gistlibby LogSnag