请教什么是频谱的瀑布图?
请教一下频谱的瀑布图指什么概念?我的理解应该是要引入时间的概念,通过不同的颜色在一个二维图里面表达三维信息,但是不是很确定,想请各位大神讲一下,标准的瀑布图的横轴,纵轴都表示什么意思,完了matlab怎么去仿真实现?谢谢~~我的意思不是需要matlab里面waterfall的那种瀑布图,而是二维的,在实际仪器显示里面的那种瀑布图~
看一下help文件 本帖最后由 粥糊了耶 于 2012-11-6 17:12 编辑
瀑布图的横轴是频率,纵轴是时间,幅值能够直接看到,不是颜色刻度所表示的;
而(瀑布)彩图的第三维——颜色的深浅代表幅值的大小,横坐标和纵坐标仍然分别是频率和时间file:///E:/无标题-1.png。
file:///E:/无标题-2.png
这是(瀑布)彩图,上一页就是瀑布图。
粥糊了耶 发表于 2012-11-6 17:08 static/image/common/back.gif
瀑布图的横轴是频率,纵轴是时间,幅值能够直接看到,不是颜色刻度所表示的;
而(瀑布)彩图的第三维—— ...
为什么图片显示不了呢 粥糊了耶 发表于 2012-11-6 17:08 static/image/common/back.gif
瀑布图的横轴是频率,纵轴是时间,幅值能够直接看到,不是颜色刻度所表示的;
而(瀑布)彩图的第三维—— ...
谢谢,请问为什么没图呢?哦,你瀑布图指waterfall吧,而瀑布彩图指仪器中的那种把?是不是只是在彩图中将幅值用颜色表示了? 本帖最后由 粥糊了耶 于 2012-11-17 21:54 编辑
yyxi0226 发表于 2012-11-15 21:46 http://forum.chinavib.com/static/image/common/back.gif
谢谢,请问为什么没图呢?哦,你瀑布图指waterfall吧,而瀑布彩图指仪器中的那种把?是不是只是在彩图中将 ...
对的,瀑布图的第三维是幅值,为方便观察,一般有个偏视角,而彩图的第三维是颜色。 本帖最后由 westrongmc 于 2012-11-18 00:00 编辑
鉴于前面的图不完整,补充几张图:
上面的面是由matlab的file exchange里的daqwaterfall.m生成的,
http://www.mathworks.com/matlabcentral/fileexchange/2904-3d-waterfall-plot-demo
源码粘贴如下:
function varargout = daqwaterfall(varargin)
% daqwaterfall
%
%Displays a waterfall plot with data streamed in from the Data
%Acquisition Toolbox.This demo was created using Guide in MATLAB 6.5.
%This demo uses a lot of the code from demoai_fft.
%
%The input source is hardcoded to channel one of the system soundcard.
%You should be able to change this if necessary by modifying the
%parameter in the I N P U T S section of the file daqwaterfall.m
%
% Last Modified by GUIDE v2.5 06-Jan-2003 23:34:34
% Author: Daniel Lee (dlee@mathworks.com)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton',gui_Singleton, ...
'gui_OpeningFcn', @daqwaterfall_OpeningFcn, ...
'gui_OutputFcn',@daqwaterfall_OutputFcn, ...
'gui_LayoutFcn',[] , ...
'gui_Callback', []);
if nargin & isstr(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
= gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before daqwaterfall is made visible.
function daqwaterfall_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdatareserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to daqwaterfall (see VARARGIN)
% Choose default command line output for daqwaterfall
handles.output = hObject;
%%%%%%%%%%%%%%%%%%%%%%%
% ++++ I N P U T S ++++
%%%%%%%%%%%%%%%%%%%%%%%
% Change these settings to select a different source.
handles.adaptor = 'winsound';
handles.id = 0;
handles.chan = 1;
handles.samplesPerTrigger = 2048*2;
handles.sampleRate = 44100;
handles.numTraces = 20; % number of traces to show in the waterfall.
handles.cycleTime = .9; % Proportional to the amount of time spent per
%visualization on CycleAll setting.
%%%%%%%%%%%%%%%%%%%%%%%
% ---- I N P U T S ----
%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ++++ S E T U P T H E F I G U R E ++++
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*%%%%%%
set(handles.figure1,'Color',get(handles.tTitle,'BackgroundColor'));
axes(handles.axes1);
handles.hLine1 = plot(zeros(1,handles.samplesPerTrigger)');
set(handles.hLine1,'Color', [.1 .1 0.5]);
set(handles.axes1,'Color',)
set(handles.axes1,'XGrid','on','YGrid','on')
t=title('Time Domain Signal','Color',[.05 .05 .25],'FontWeight','Bold','FontSize',9);
xlabel('Time (s)','FontSize',8);
ylabel('Voltage (V)','FontSize',8);
axes(handles.axes2);
handles.hLine2 = plot(zeros(1,handles.samplesPerTrigger/2)');
set(handles.hLine2,'Color', [.1 0.5 .1]);
set(handles.axes2,'Color',)
set(handles.axes2,'XGrid','on','YGrid','on')
t=title('Frequency Domain Signal','Color',[.05 0.25 .05],'FontWeight','Bold','FontSize',9);
xlabel('Frequency (Hz)','FontSize',8);
ylabel('Magnitude (dB)','FontSize',8);
axes(handles.axes3);
set(handles.axes3,'View',);
set(handles.axes3,'Color',);
grid(handles.axes3,'on');
h = get(handles.axes3,'title');
set(h,'string','Waterfall Plot','FontWeight','Bold','Color',[.25 .05 .05],'FontSize',9);
h = get(handles.axes3,'ylabel');
set(h,'string','Frequency (Hz)','FontSize',8);
h = get(handles.axes3,'zlabel');
set(h,'string','Magnitude (dB)','FontSize',8);
set(hObject,'RendererMode','Manual')%If you don't do this, the surface plot
set(hObject,'Renderer','OpenGL') % will draw VERY slowly.
set(handles.tSource,'String',sprintf('%s:%d',handles.adaptor,handles.id));
set(handles.tChannel,'String',num2str(handles.chan));
set(handles.poSampleRate,'String',[{'44100'},{'22000'},{'8000'}]);
set(handles.poPlotType,'String',[{'CycleAll'},{'Classic'},{'Classic(Top)'},{'Mosaic'},{'Waterfall'},{'Rotate'}]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---- S E T U P T H E F I G U R E ----
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ++++ D R A WT H EL O G O ++++
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
L = 40*membrane(1,25);
axes(handles.axes4);
set(handles.axes4,...
'CameraPosition', [-193.4013 -265.1546220.4819],...
'XLim',, ...
'YLim',, ...
'Visible','off', ...
'ZLim',[-13 40]);
s = surface(L, ...
'EdgeColor','none', ...
'FaceColor',, ...
'FaceLighting','phong', ...
'AmbientStrength',0.3, ...
'DiffuseStrength',0.6, ...
'Clipping','off',...
'BackFaceLighting','lit', ...
'SpecularStrength',1.1, ...
'SpecularColorReflectance',1, ...
'SpecularExponent',7);
l1 = light('Position',, ...
'Style','local', ...
'Color',);
l2 = light('Position',[.5 -1 .4], ...
'Color',);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---- D R A WT H EL O G O ----
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ai=localSetupAI(handles);
handles.ai = ai;
% Update handles structure
guidata(hObject, handles);
localStartAI(ai);
% UIWAIT makes daqwaterfall wait for user response (see UIRESUME)
% uiwait(handles.figure1);
function localStartAI(ai)
%%%%%%%%%%%%%%%%%%%%%%%%%%
% ++++ S T A R TA I ++++
%%%%%%%%%%%%%%%%%%%%%%%%%%
start(ai);
trigger(ai);
%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---- S T A R TA I ----
%%%%%%%%%%%%%%%%%%%%%%%%%%
function localStopAI(ai)
%%%%%%%%%%%%%%%%%%%%%%%%
% ++++ S T O PA I ++++
%%%%%%%%%%%%%%%%%%%%%%%%
stop(ai);
delete(ai);
%%%%%%%%%%%%%%%%%%%%%%%%
% ---- S T O PA I ----
%%%%%%%%%%%%%%%%%%%%%%%%
function ai=localSetupAI(handles)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ++++ S E T U P T H E A N A L O G I N P U T ++++
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Object Configuration.
% Create an analog input object with one channel.
ai = analoginput(handles.adaptor, handles.id);
addchannel(ai, handles.chan);
% Configure the callback to update the display.
set(ai, 'TimerFcn', @localfftShowData);
% Configure the analog input object.
set(ai, 'SampleRate', handles.sampleRate);
%%dsw
set(ai,'logfilename','datalogdsw.daq');
set(ai,'loggingmode','disk&memory');
% Configure the analog input object to trigger manually twice.
%We do this because we are using peekdata to acquire the data in
% a timer callback function.
%The first trigger will fill the buffer with handles.samplesPerTrigger
% number of samples.We'll know we have enough samples to start
% processing data when the analog input object's SamplesAvailable property
% is equal to handles.samplesPerTrigger.
%The analog input object will then wait for
% another manual trigger, and while it is waiting the object will still be
% in its running state, which means the timer event will run. To keep the
% object in the running state, we need only never manually trigger this
% second trigger.
%Had we set the TriggerRepeat to 0, the analog input object would stop
% after the first trigger and the timer functions would stop running.
%
set(ai, 'SamplesPerTrigger', handles.samplesPerTrigger);
set(ai, 'TriggerRepeat', 1);
set(ai, 'TriggerType', 'manual');
% Initialize callback parameters.The TimerAction is initialized
% after figure has been created.
set(ai, 'TimerPeriod', 0.01);
set(ai, 'BufferingConfig',);
% Initialize time and frequency plots with lines of y=0
d=zeros(1,handles.samplesPerTrigger);
time = 1:handles.samplesPerTrigger;
f=1:handles.samplesPerTrigger/2;
mag=zeros(1,handles.samplesPerTrigger/2);
% Store state information in the analog input objects UserData area.
data.storedFFTsIndex = 1;
data.plotSurf = 0;
data.ai = ai;
data.getdata = ;
data.daqfft = ;
data.handle = [];
data.figureHandles = handles;
data.view = ;
data.rotateStep = 4;
data.counter = 0;
% Set the object's UserData to data.
set(data.ai, 'UserData', data);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---- S E T U P T H E A N A L O G I N P U T ----
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Outputs from this function are returned to the command line.
function varargout = daqwaterfall_OutputFcn(hObject, eventdata, handles)
% varargoutcell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdatareserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pbExit or when you press
% the figure close 'X' button (I set this function to
% the figures CloseRequestFcn in GUIDE).
function pbExit_Callback(hObject, eventdata, handles)
% hObject handle to pbExit (see GCBO)
% eventdatareserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
localStopAI(handles.ai);
closereq;
% --- Executes during object creation, after setting all properties.
function poSampleRate_CreateFcn(hObject, eventdata, handles)
% hObject handle to poSampleRate (see GCBO)
% eventdatareserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ++++ C H A N G E T H E S A M P L E R A T E++++
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Executes on selection change in poSampleRate.
function poSampleRate_Callback(hObject, eventdata, handles)
% hObject handle to poSampleRate (see GCBO)
% eventdatareserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns poSampleRate contents as cell array
% contents{get(hObject,'Value')} returns selected item from poSampleRate
% First, stop and delete the current analog input object
localStopAI(handles.ai);
% Extract the new samplerate.
v=get(handles.poSampleRate,'Value');
s=get(handles.poSampleRate,'String');
handles.sampleRate = str2num(s{v});
% Create a new analog input with the new sample rate.
handles.ai = localSetupAI(handles);
% Update handles structure
guidata(hObject, handles);
% Restart the analog input
localStartAI(handles.ai);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---- C H A N G E T H E S A M P L E R A T E----
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ***********************************************************************
% Calculate the fft of the data.(Copied from demoai_fft.m)
function = localDaqfft(data,Fs,blockSize)
% Calculate the fft of the data.
xFFT = fft(data);
xfft = abs(xFFT);
% Avoid taking the log of 0.
index = find(xfft == 0);
xfft(index) = 1e-17;
mag = 20*log10(xfft);
mag = mag(1:blockSize/2);
f = (0:length(mag)-1)*Fs/blockSize;
f = f(:);
% ***********************************************************************
% Update the plot. This routine is a Timer callback, it is called
%automatically at a preset time interval. See line 184 for where
%this routine is assigned as a callback
function localfftShowData(obj,event)
if (get(obj,'SamplesAvailable') >= obj.SamplesPerTrigger)
% Get the handles.
data = obj.UserData;
handles = data.figureHandles;
%%dsw
% samplesN = 2048*2;
% dd = getdata(obj, samplesN);
% Execute a peekdata.
x = peekdata(obj, obj.SamplesPerTrigger);
% FFT calculation.
Fs = obj.SampleRate;
blockSize = obj.SamplesPerTrigger;
= localDaqfft(x,Fs,blockSize);
% Dynamically modify Analog axis as we go.
maxX=max(x);
minX=min(x);
yax1=get(handles.axes1,'YLim');
yax1(1)=minX - .0001; % need to subtract a value to make sure yax(1) never equals yax(2)
yax1(2)=maxX + .0001;
set(handles.axes1,'YLim',yax1)
set(handles.axes1,'XLim',)
% Dynamically modify Frequency axis as we go.
maxF=max(f);
minF=min(f);
xax=get(handles.axes2,'XLim');
xax(1)=minF;
xax(2)=maxF;
set(handles.axes2,'XLim',xax)
% Dynamically modify Magnitude axis as we go.
maxM=max(mag);
minM=min(mag);
yax2=get(handles.axes2,'YLim');
yax2(1)=minM - .0001;
yax2(2)=maxM + .0001;
set(handles.axes2,'YLim',yax2)
% Update the line plots.
set(handles.hLine1, 'XData', /obj.SampleRate, 'YData', x(:,1));
set(handles.hLine2, 'XData', f(:,1), 'YData', mag(:,1));
% Find the frequency at which the max signal strength is at.
= max(mag);
set(handles.tFreq,'String',sprintf('%4.1d Hz',f(maxindex)));
% Store the current FFT into the array of FFTs used for the waterfall.
data.storedFFTs(data.storedFFTsIndex,:) = mag';
% This circular shift is used so that when we display the 3D plot, the
%newest FFT will appear in 'front' and the oldest in 'back'.
% To understand this, note how the plotting routines are using this fftOrder
%array to reorder the FFTs stored in data.storedFFTs and also note
%how data.storedFFTsIndex is used to store FFTs in data.storedFFTs.
%
fftOrder = 1:handles.numTraces;
fftOrder = circshift(fftOrder,[ 1 -data.storedFFTsIndex ]);
data.storedFFTsIndex = data.storedFFTsIndex + 1;
if (data.storedFFTsIndex > handles.numTraces)
data.storedFFTsIndex = 1;
data.plotSurf = 1; % Indicates a full history is stored.
end
% Update the surface plot if we have a full history.
if (data.plotSurf)
cla(handles.axes3);
v=get(handles.poPlotType,'Value');
s=get(handles.poPlotType,'String');
switch s{v}
case 'Classic'
data.view= ;
data=localClassic(handles,data,f,fftOrder);
case 'Classic(Top)'
data.view= ;
data=localClassic(handles,data,f,fftOrder);
case 'Mosaic'
data.view= ;
data=localMosaic(handles,data,f,fftOrder);
case 'Waterfall'
data.view = ;
data=localWaterfall(handles,data,f,fftOrder,yax2);
case 'Rotate'
data=localRotate(handles,data,f,fftOrder);
case 'CycleAll'
data=localCycleAll(handles,data,f,fftOrder);
end
end
set(data.ai, 'UserData', data);
drawnow;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ++++ V I S U A L I Z A T I O N ++++
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function data=localClassic(handles,data,f,fftOrder)
= meshgrid(1:handles.numTraces,f(1:end));
surf(X,Y,data.storedFFTs(fftOrder,:)','parent',handles.axes3);
set(handles.axes3,'XLim',,'YLim',)
shading(handles.axes3,'interp');
set(handles.axes3,'View',data.view)
function data=localMosaic(handles,data,f,fftOrder)
= meshgrid(1:handles.numTraces,f(1:10:end));
surf(X,Y,data.storedFFTs(fftOrder,(1:10:end))','parent',handles.axes3);
set(handles.axes3,'XLim',,'YLim',)
set(handles.axes3,'View',data.view)
function data=localWaterfall(handles,data,f,fftOrder,yax2)
= meshgrid(1:handles.numTraces,f(1:end));
p=plot3(X,Y,data.storedFFTs(fftOrder,:)','parent',handles.axes3);
% rotate the color map of the lines in the plot3
map= linspace(0,1,handles.numTraces);
map2 = linspace(1,0,handles.numTraces);
rotatemap= map(fftOrder);
rotatemap2 = map2(fftOrder);
for k=1:handles.numTraces;
set(p(k),'Color',);
end
set(handles.axes3,'XLim',,'YLim',);
shading(handles.axes3,'interp');
set(handles.axes3,'View',data.view)
function data=localRotate(handles,data,f,fftOrder)
= meshgrid(1:handles.numTraces,f(1:8:end));
surf(X,Y,data.storedFFTs(fftOrder,(1:8:end))','parent',handles.axes3);
set(handles.axes3,'XLim',,'YLim',)
set(handles.axes3,'View',data.view)
% Rotate the view point.
data.view(1) = 90;
if data.view(2) >= 90-data.rotateStep
data.rotateStep = -4;
elseif data.view(2) <= -90-data.rotateStep
data.rotateStep = 4;
end
data.view(2) = data.view(2)+data.rotateStep;
function data=localCycleAll(handles,data,f,fftOrder)
data.counter = data.counter + get(data.ai,'TimerPeriod');
if data.counter > 5*handles.cycleTime
data.counter = 0;
elseif data.counter > 4*handles.cycleTime
data=localRotate(handles,data,f,fftOrder);
elseif data.counter > 3*handles.cycleTime
data.view= ;
data=localWaterfall(handles,data,f,fftOrder);
elseif data.counter > 2*handles.cycleTime
data.view= ;
data=localMosaic(handles,data,f,fftOrder);
elseif data.counter > 1*handles.cycleTime
data.view= ;
data=localClassic(handles,data,f,fftOrder);
else
data.view= ;
data=localClassic(handles,data,f,fftOrder);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---- V I S U A L I Z A T I O N ----
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Executes during object creation, after setting all properties.
function poPlotType_CreateFcn(hObject, eventdata, handles)
% hObject handle to poPlotType (see GCBO)
% eventdatareserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in poPlotType.
function poPlotType_Callback(hObject, eventdata, handles)
% hObject handle to poPlotType (see GCBO)
% eventdatareserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns poPlotType contents as cell array
% contents{get(hObject,'Value')} returns selected item from poPlotType
页:
[1]