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

📄 dbspec.m

📁 绘制地震图形matlab软件包,可采用不同方式进行剖面成图实现
💻 M
字号:
function hs=dbspec(t,s,flag,n)
% DBSPEC: plots a Fourier amplitude spectrum using a decibel scale.
%
% dbspec(t,s,flag,n)
% dbspec(t,s,flag)
% dbspec(t,s)
%
% DBSPEC opens up a new figure window and plots a simple Fourier
% decibel spectrum (unwrapped).
% If s is a vector, then a single curve is
% plotted showing the amplitude spectrum of s. If s is a matrix,
% then a separate spectral curve is determined and plotted for each
% row of s. (The decibel reference is max(max(S)) where S is the
% amplitude spectrum of s.)
%
% Note: DBSPEC uses PLOT for display and calls SIMPLEZOOM 
% to provide an interactive Zoom
%
% s= input trace
% t= input time vector
% flag= 0... apply an n length mwindow to s before transforming
%       1... apply an n length half-mwindow to s before transforming
%       2... transform directly without windowing
% ************* default=2 **************
% n= transform length, if not supplied, then fft length
%    will be length(s)
% 
% 
% by G.F. Margrave, May 1991
%
% NOTE: It is illegal for you to use this software for a purpose other
% than non-profit education or research UNLESS you are employed by a CREWES
% Project sponsor. By using this software, you are agreeing to the terms
% detailed in this software's Matlab source file.
 
% BEGIN TERMS OF USE LICENSE
%
% This SOFTWARE is maintained by the CREWES Project at the Department
% of Geology and Geophysics of the University of Calgary, Calgary,
% Alberta, Canada.  The copyright and ownership is jointly held by 
% its author (identified above) and the CREWES Project.  The CREWES 
% project may be contacted via email at:  crewesinfo@crewes.org
% 
% The term 'SOFTWARE' refers to the Matlab source code, translations to
% any other computer language, or object code
%
% Terms of use of this SOFTWARE
%
% 1) Use of this SOFTWARE by any for-profit commercial organization is
%    expressly forbidden unless said organization is a CREWES Project
%    Sponsor.
%
% 2) A CREWES Project sponsor may use this SOFTWARE under the terms of the 
%    CREWES Project Sponsorship agreement.
%
% 3) A student or employee of a non-profit educational institution may 
%    use this SOFTWARE subject to the following terms and conditions:
%    - this SOFTWARE is for teaching or research purposes only.
%    - this SOFTWARE may be distributed to other students or researchers 
%      provided that these license terms are included.
%    - reselling the SOFTWARE, or including it or any portion of it, in any
%      software that will be resold is expressly forbidden.
%    - transfering the SOFTWARE in any form to a commercial firm or any 
%      other for-profit organization is expressly forbidden.
%
% END TERMS OF USE LICENSE

figure 
[m,nn]=size(s);
if(nargin<4)
   n=length(s);
 end
if nargin<3
   flag=2;
end

%test for a row vector
if(m==1)
   s=s(:);
end

%if m>nn, s=s.'; end

% test to see if s is complex
test=imag(s);
mag=sum(abs(test));
% branch accordingly
if(mag>0.0)
   if flag <2
      mw=ones(size(s(1,:)));
      if flag==0, mw=mwindow(s(1,:),20);end
      if flag==1, mw=mwhalf(s(1,:),20);end
      for it=1:m, s(it,:)=s(it,:).*mw;end
    end
    %spec=abs(fftshiftm(fft(s.',n)));
    spec=abs(fftshiftm(fft(s,n)));
    db=20*log10(spec/max(max(spec)));
    dt=t(2)-t(1);
    fn=1./(2*dt);
    df=1/((n-1)*dt);
    f=linspace(-fn,fn-df,n);
 else
    if flag <2
      mw=ones(size(s(1,:)));
      if flag==0, mw=mwindow(s(1,:),20);end
      if flag==1, mw=mwhalf(s(1,:),20);end
      for it=1:m, s(it,:)=s(it,:).*mw;end
    end
    %s=abs(fft(s',n));
    s=abs(fft(s,n));
    spec=s(1:round(n/2),:);
    db=20*log10(spec/max(max(spec)));
    dt=t(2)-t(1);
    fn=1./(2*dt);
    f=linspace(0.,fn,round(n/2));
 end
% now plot it
   hs=plot(f,db);
   xlabel('Frequency (Hz)');
   ylabel(' db down');
	  grid;
	  %set(gca,'xlabel',text(0,0,' Frequency (Hz)'));
	  %set(gca,'ylabel',text(0,0,' db down'));
   simplezoom 

⌨️ 快捷键说明

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