資源簡介
matlab求解差分方程程序
%差分方程為:
%y(n)-2y(n-1)+3y(n-2)=4u(n)-5u(n-1)+6u(n-2)-7u(n-3)
%初始條件:x(-1)=1,x(-2)=-1,y(-1)=-1,y(-2)=1,求系統(tǒng)輸出y(n)
clear all;
close all;
clc;
b=[4,-5,6,-7];
a=[1,-2,3];
x0=[1,-1,0];
y0=[-1,1];
xic=filtic(b,a,y0,x0)%filtic函數(shù)用于為filter函數(shù)選擇初始條件
bxplus=1;
axplus=[1,-1];
ayplus=conv(a,axplus)%計算多項式乘積的系數(shù)
byplus=conv(b,bxplus)+conv(xic,axplus)
[R,P,K]=residuez(byplus,ayplus)%留數(shù)法求解z變換.R為留數(shù),P為極點(diǎn),K為直接項系數(shù),b-分子,a-分母
Mp=abs(P)
Ap=angle(P)*180/pi
N=100;
n=0:N-1;
xn=ones(1,N);
yn=filter(b,a,xn,xic);
plot(n,yn)
代碼片段和文件信息
%差分方程為:
%y(n)-2y(n-1)+3y(n-2)=4u(n)-5u(n-1)+6u(n-2)-7u(n-3)
%初始條件:x(-1)=1x(-2)=-1y(-1)=-1y(-2)=1求系統(tǒng)輸出y(n)
clear?all;
close?all;
clc;
b=[4-56-7];
a=[1-23];
x0=[1-10];
y0=[-11];
xic=filtic(bay0x0)%filtic函數(shù)用于為filter函數(shù)選擇初始條件
bxplus=1;
axplus=[1-1];
ayplus=conv(aaxplus)%計算多項式乘積的系數(shù)
byplus=conv(bbxplus)+conv(xicaxplus)
- 上一篇:牛拉法(極坐標(biāo)形式)
- 下一篇:MATLAB 簡易鋼琴 源代碼
評論
共有 條評論