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

📄 fsbuild.m

📁 很多matlab的源代码
💻 M
字号:
% FSBUILD Signal reconstruction from Fourier series coefficients.%% FSBUILD is a script file that allows for signal reconstruction.% ADSP Toolbox: Version 2.0 % For use with "Analog and Digital Signal Processing", 2nd Ed.% Published by PWS Publishing Co.%% Ashok Ambardar, EE Dept. MTU, Houghton, MI 49931, USA% http://www.ee.mtu/faculty/akambard.html% e-mail: akambard@mtu.edu% Copyright (c) 1998clc,echo off,disp(' Signal Recostruction from Fourier Series Coefficients')disp('Please enter relevant information at each prompt')%Prompt for relevant information:T=input('Time Period : ');d=1;sy=input('Half wave Symmetry(0=N, 1=Y) : ');if sy==1,d=2;endlmax=input('Number of NONZERO Harmonics to be used: ');lm=min(20,lmax);nh=d*lmax-d+1;k=1:d:nh; %Choose all harmonics if d=1 or odd ones if d=2kk=k(1:lm);ll=length(kk);a0=input('Average value : ');disp(' ')disp(' Enter coefficients as an array or function of k e.g. (1/pi)./k')disp(' If all coefficients are zero enter 0 or simply hit ENTER')disp(' If arrays, both a(k) and b(k) must be the same length')ak=input('Coefficients a(k)= : ');if isempty(ak),ak=0;endbk=input('Coefficients b(k)= : ');if isempty(bk),bk=0;endf=(0.05:.05:lm)/T; %Set up frequency array for envelopesf=input('Smoothing window in single quotes (Hit ENTER for no smoothing): ');if isempty(sf),sf='boxcar';endif ak==0,ak=zeros(1,lmax);end,ak=[a0 ak];  %Set up coefficient arraysif bk==0,bk=zeros(1,lmax);end,bk=[0 bk];k=[0 k];l=lmax+1;kk=[0 kk];ll=ll+1;f1=kk/T;N=200;f0=1/T;t=0:T/N:T;  %Set up 129 point time arrayc=sqrt(ak(1:ll).*ak(1:ll)+bk(1:ll).*bk(1:ll));  %Magnitude spectrum vx=matverch; if vx < 4, eval('clg');else,eval('clf');endhold off,subplot(221)dtplot(f1,c,'.'),title('Magnitude spectrum'),a=1;z=zeros(4,length(t));y=ak(1)+z(1,:);y3=y;sc=windo(sf,2*nh+1);sc=sc(nh+2:2*nh+1);sc=sc(1:d:nh);for jj=1:d:nha=a+1;sm=(ak(a)*cos(2*pi*f0*jj*t)+bk(a)*sin(2*pi*f0*jj*t));y=y+sm;y3=y3+sm*sc(a-1);if a==2;z(4,:)=y;end,if a==3;z(3,:)=y;end,if a==4;z(2,:)=y;endendz(1,:)=y;mm=max(max(z));nn=min(min(z));ax=[0 T nn-0.1*abs(mm) mm+0.1*abs(mm)];subplot(223),axis(ax);plot(t,z),axis(ax);title('Intermediate Reconstructions')subplot(222),axis(ax);plot(t,y),axis(ax);title('Final Reconstruction')subplot(224),axis(ax);plot(t,y3),axis(ax);title(['Smoothing: ' sf ' window'])pause,subplot,hold off

⌨️ 快捷键说明

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