下面是一段matlab程序,画曲线用的。 但不知道最后一句里的”--rs“是什么意思。请教一下大家了!

下面是一段matlab程序,画曲线用的。 但不知道最后一句里的”--rs“是什么意思。请教一下大家了!,第1张

传递给plot的一个曲线绘制参数.

matlab help里有解释.我使用时一般都默认.

色彩字符颜色线型字符线型格式标记符号数据点形式标记符号数据点形式

y 黄- 实线. 点<小于号

m 紫: 点线o 圆s 正方形

c 青-. 点划线x 叉号d 菱形

r 红- - 虚线+ 加号h 六角星

g 绿* 星号p 五角星

b 蓝v 向下三角形

w 白^ 向上三角形

k 黑>大于号

>>help plot:

PLOT Linear plot.

PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix,

then the vector is plotted versus the rows or columns of the matrix,

whichever line up. If X is a scalar and Y is a vector, disconnected

line objects are created and plotted as discrete points vertically at

X.

PLOT(Y) plots the columns of Y versus their index.

If Y is complex, PLOT(Y) is equivalent to PLOT(real(Y),imag(Y)).

In all other uses of PLOT, the imaginary part is ignored.

Various line types, plot symbols and colors may be obtained with

PLOT(X,Y,S) where S is a character string made from one element

from any or all the following 3 columns:

b blue . point - solid

g green o circle : dotted

r red x x-mark -.dashdot

c cyan + plus --dashed

m magenta * star (none) no line

y yellows square

k black d diamond

w white v triangle (down)

^ triangle (up)

<triangle (left)

>triangle (right)

p pentagram

h hexagram

For example, PLOT(X,Y,'c+:') plots a cyan dotted line with a plus

at each data pointPLOT(X,Y,'bd') plots blue diamond at each data

point but does not draw any line.

PLOT(X1,Y1,S1,X2,Y2,S2,X3,Y3,S3,...) combines the plots defined by

the (X,Y,S) triples, where the X's and Y's are vectors or matrices

and the S's are strings.

For example, PLOT(X,Y,'y-',X,Y,'go') plots the data twice, with a

solid yellow line interpolating green circles at the data points.

The PLOT command, if no color is specified, makes automatic use of

the colors specified by the axes ColorOrder property. By default,

PLOT cycles through the colors in the ColorOrder property. For

monochrome systems, PLOT cycles over the axes LineStyleOrder property.

Note that RGB colors in the ColorOrder property may differ from

similarly-named colors in the (X,Y,S) triples. For example, the

second axes ColorOrder property is medium green with RGB [0 .5 0],

while PLOT(X,Y,'g') plots a green line with RGB [0 1 0].

If you do not specify a marker type, PLOT uses no marker.

If you do not specify a line style, PLOT uses a solid line.

PLOT(AX,...) plots into the axes with handle AX.

PLOT returns a column vector of handles to lineseries objects, one

handle per plotted line.

The X,Y pairs, or X,Y,S triples, can be followed by

parameter/value pairs to specify additional properties

of the lines. For example, PLOT(X,Y,'LineWidth',2,'Color',[.6 0 0])

will create a plot with a dark red line width of 2 points.

Example

x = -pi:pi/10:pi

y = tan(sin(x)) - sin(tan(x))

plot(x,y,'--rs','LineWidth',2,...

'MarkerEdgeColor','k',...

'MarkerFaceColor','g',...

'MarkerSize',10)

clcclear all

%归一化模拟切比雪夫I型低通滤波器的设计

Wp=2*pi*1000Ws=2*pi*1500rp=3rs=30%设计滤波器的参数    

wp=1ws=Ws/Wp                       %频带变换得到归一化滤波器

[N,wc]=cheb1ord(wp,ws,rp,rs,'s')    %计算滤波器阶数和3dB截止频率  

[z,p,k]=cheb1ap(N,rp)               %计算归一化滤波器的零极点

[b,a]=zp2tf(z,p,k)                  %计算归一化滤波器系统函数的系数

w0=0:0.05*pi:2*pi

[h0,w0]=freqs(b,a,w0)               %求频率响应 

figure(1)

plot(w0,20*log10(abs(h0)),'k')

title('归一化模拟且比雪夫I型低通滤波器')

xlabel('频率f/Hz')ylabel('幅度/dB')grid

%一般低通切比雪夫低通滤波器的设计

[B,A]=lp2lp(b,a,Wp)                 %将归一化滤波器转换为一般模拟滤波器

w1=0:2*pi*100:2*pi*30000

[h1,w1]=freqs(B,A,w1)

figure(2)

plot(w1/(2*pi),20*log10(abs(h1)),'k')

title('一般模拟且比雪夫I型低通滤波器')

xlabel('频率f/Hz')ylabel('幅度/dB')grid

%冲激响应不变法设计低通巴特沃斯数字滤波器

Fs=10000                            %采样频率 

Wp1=Wp/FsWs1=Ws/Fs

rp1=3rs1=30                        %设计滤波器的参数  

[N1,Wn]=cheb1ord(Wp,Ws,rp1,rs1,'s')  %计算滤波器阶数

[b1,a1]=cheby1(N1,rp1,Wn,'s')       %样本AF的系数函数的分子分母系数

[bz,az]=impinvar(b1,a1,Fs)          %冲激响应不变法从AF到DF变换

[C1,B1,A1]=dir2par(bz,az)            %直接形式转换为并联型

w2=[Wp1,Ws1]                        %数字临界频率

[H,f]=freqz(bz,az)                  %绘制数字滤波器的幅频特性和相频特性

[db,mag,pha,grd,f]=freqz_m(bz,az)   %扩展函数检验滤波器的其他特性

figure(3)

plot(f/pi,db,'k')

title('冲激响应不变法设计低通切比雪夫I型数字滤波器')

xlabel('角频率w/pi')ylabel('振幅/dB')

axis([0,0.35,-30,5])grid

%用设计好的滤波器对信号进滤波处理

figure(4)

f1=500f2=4000                      %输入信号的频率

N=100                               %数据长度

dt=1/Fsn=0:N-1t=n*dt              %采样间隔和时间序列

x=sin(2*pi*f1*t)+0.5*cos(2*pi*f2*t) %输入信号

subplot(2,1,1),plot(t,x),title('输入信号')

y=filtfilt(bz,az,x)                 %用滤波器进行滤波处理

y1=filter(bz,az,x)                  %进行滤波处理

subplot(2,1,2),plot(t,y,t,y1,':'),title('输出信号')xlabel('时间/s')

legend('filtfilt','filter')          %加图例

freqz_m.m文件

function[db,mag,pha,grd,w]=freqz_m(b,a)

[H,w]=freqz(b,a,1000,'whole')

mag=abs(H)

db=20*log10((mag+eps)/max(mag))

pha=angle(H)

grd=grpdelay(pha)

dir2par.m文件

function [C,B,A] = dir2par(b,a)

M=length(b)N=length(a)

[r1,p1,C]=residuez(b,a)

p=cplxpair(p1,10000000*eps)

I=cplxcomp(p1,p)

r=r1(I)

K=floor(N/2)B=zeros(K,2)A=zeros(K,3)

if K*2==N

    for i=1:2:N-2

        Brow=r(i:1:i+1,:)

        Arow=p(i:1:i+1,:)

        [Brow,Arow]=residuez(Brow,Arow,[])

        B(fix((i+1)/2),:)=real(Brow)

        A(fix((i+1)/2),:)=real(Arow)

    end

    [Brow,Arow]=residuez(r(N-1),p(N-1),[])

    B(K,:)=[real(Brow) 0]A(K,:)=[real(Arow) 0]

else

    for i=1:2:N-1

        Brow=r(i:1:i+1,:)

        Arow=p(i:1:i+1,:)

        [Brow,Arow]=residuez(Brow,Arow,[])

        B(fix((i+1)/2),:)=real(Brow)

        A(fix((i+1)/2),:)=real(Arow)

    end

end

cplxcomp.m文件

function I=cplxcomp(p1,p2)

I=[]

for j=1:1:length(p2)

    for i=1:1:length(p1)

        if(abs(p1(i)-p2(j))<0.0001)

            I=[I,i]

        end

    end

end

I=I'


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11372390.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-15
下一篇 2023-05-15

发表评论

登录后才能评论

评论列表(0条)

保存