⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fg_07_08.m

📁 英文书《Digital Signal Processing with Examples in MATLAB》附带的MATLAB实例
💻 M
字号:
% fg_07_08          Frequency functions of sine and image.
sp_fig(1);
N=65536;
x=zeros(2,N);

% Sine wave in x(1,:).
x(1,:)=7.499*sin(2*pi*(1:N)/(N/2));
subplot(2,2,1);
line([0:N-1]/(N/2),x(1,:),'color','r'); grid on;
set(gca,'fontsize',16);
title('x=7.5sin4\pit');
xlabel('t'); ylabel('x(t)');
axis([0 2 -8 8]);

% Lena in array xx, then x(2,:).
xx=zeros(256,256);
fid=fopen(['lena.txt']);
for row=(1:256)
 xx(1:256,row)=fscanf(fid, ...
  '%4d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d\n',256);
end
xx=xx'+20;
fclose(fid);
subplot(2,2,2);
colormap(gray(256));
image(xx); axis square;
set(gca,'fontsize',16);
set(gca,'xtick',[1 100 200],'ytick',[1 100 200]);
title('Grey-scale image');
x(2,:)=row_vec(xx);

% Frequency plots.
ax=[-8 8 0 .2; 0 256 0 .015];
clr=['r','k'];
tl=['Uniform; \sigma=4.33 ';'Gaussian; \sigma=2.00'];
for ip=1:1,
   [f,x1,x2]=freq(x(ip,:));
   subplot(2,2,ip+2);
   axis(ax(ip,:));
   set(gca,'fontsize',16);
   xa=x1:x2;
   xlabel('n'); ylabel('       f_n');
   if(ip==1),
      set(gca,'xtick',[-8:2:8]);
      line([xa;xa],[zeros(1,x2-x1+1);f],'color','k'); grid;
      line(xa,f,'color',clr(ip),'linestyle','none','marker','*');
   else
      set(gca,'xtick',[0:64:256]);
      line(xa,f,'color','k'); grid on;
   end
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -