matlab tf2ss,Convert transfer function filter parameters to state-space form

A one-dimensional discrete-time oscillating system consists of a unit mass, m, attached to a wall by a spring of unit elastic constant. A sensor samples the acceleration, a, of the mass at Fs=5 Hz.

8725e787154102c7eaa70a8e6470f91f.png

Generate 50 time samples. Define the sampling interval Δt=1/Fs.

Fs = 5;

dt = 1/Fs;

N = 50;

t = dt*(0:N-1);

u = [1 zeros(1,N-1)];

The transfer function of the system has an analytic expression:

H(z)=1-z-1(1+cosΔt)+z-2cosΔt1-2z-1cosΔt+z-2.

The system is excited with a unit impulse in the positive direction. Compute the time evolution of the system using the transfer function. Plot the response.

bf = [1 -(1+cos(dt)) cos(dt)];

af = [1 -2*cos(dt) 1];

yf = filter(bf,af,u);

stem(t,yf,'o')

xlabel('t')

MassSpringSystemtf2ssExample_02.png

Find the state-space representation of the system. Compute the time evolution starting from an all-zero initial state. Compare it to the transfer function prediction.

[A,B,C,D] = tf2ss(bf,af);

x = [0;0];

for k = 1:N

y(k) = C*x + D*u(k);

x = A*x + B*u(k);

end

hold on

stem(t,y,'*')

hold off

legend('tf','ss')

f9847d1602507568ab5cc3d390dd98eb.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值