Edwin Wang's Blog

If there were no clouds, we should not enjoy the sun~~~ edwin-wang.com

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

   一直就想好好学习下Mablab的,不过总给各种各样的琐事打扰,现在好了,有整整一个暑假可以研习这个经典的软件了,图书馆借了本书,翻开就有点恐怖的架式,一堆堆似懂非懂的公式和框图,不管了,先看了再说。依我的能力看懂应该是没有问题的哈,嘻嘻。

  下面就开始咯,先为自己的这门自修课来道开菜:上采样和内插
  当然咯,算法么还是没有研究过得啦,不过是拿采样来练练手的。

  对标准sin函数的采样,x=sin(2*pi*t/10)

  采样主程序:

 1% File: c3_upsampex.m
 2M=6;
 3h=c3_lininterp(M);
 4t=0:10;
 5tu=0:60;
 6x=sin(2*pi*t/10);
 7xu=c3_upsamp(x,M);
 8subplot(3,1,1)
 9stem(t,x,'k.')
10ylabel('X')
11subplot(3,1,2)
12stem(tu,xu,'k.')
13ylabel('Xu')
14xi=conv(h,xu);
15subplot(3,1,3)
16stem(xi,'k.')
17ylabel('Xi')

  上采样函数:
1% File: c3_upsample.m
2function out=c3_upsamp(in,M)
3L=length(in);
4out=zeros(1,(L-1)*M+1);
5for j=1:L
6    out(M*(j-1)+1)=in(j);
7end
8% End of function file.

  线性内插函数:
1% File: c3_lininterp.m
2function h=c3_lininterp(M)
3h1=zeros(1,(M-1));
4for j=1:(M-1)
5    h1(j)=j/M;
6end
7h=[0,h1,1,fliplr(h1),0]
8% End of function file.

  生成的图形:
 

  不错,很能说明问题了,上采样的开销较大,线性内插的就好多了的说,嘻嘻,到这里结束^_^
posted on 2006-06-18 23:00  laughterwym  阅读(6310)  评论(0编辑  收藏  举报