?? fftplatform.m
字號(hào):
function varargout = FFTPlatForm(varargin)
% FFTPLATFORM M-file for FFTPlatForm.fig
% FFTPLATFORM, by itself, creates a new FFTPLATFORM or raises the existing
% singleton*.
%
% H = FFTPLATFORM returns the handle to a new FFTPLATFORM or the handle to
% the existing singleton*.
%
% FFTPLATFORM('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in FFTPLATFORM.M with the given input arguments.
%
% FFTPLATFORM('Property','Value',...) creates a new FFTPLATFORM or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before FFTPlatForm_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to FFTPlatForm_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help FFTPlatForm
% Last Modified by GUIDE v2.5 31-Aug-2007 08:26:30
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @FFTPlatForm_OpeningFcn, ...
'gui_OutputFcn', @FFTPlatForm_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before FFTPlatForm is made visible.
function FFTPlatForm_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to FFTPlatForm (see VARARGIN)
% Choose default command line output for FFTPlatForm
handles.output = hObject;
% set(handles.FFTPlatForm,'ToolBar','on')
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes FFTPlatForm wait for user response (see UIRESUME)
% uiwait(handles.FFTPlatForm);
str1={'FPGADataSimSoft v1.0'};
str2={'For FPGA output data processing.'};
str3={'Written by ShiXiaojuan, hyt, CO., LTD.'};
str4={'Contact: crystal_shi2006@163.com'};
str5={''};
str6={'This is the state frame.'};
handles.str=[str1;str2;str3;str4;str5;str6];
set(handles.Notes,'String',handles.str);
% --- Outputs from this function are returned to the command line.
function varargout = FFTPlatForm_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - 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 ImportData.
function ImportData_Callback(hObject, eventdata, handles)
% hObject handle to ImportData (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of ImportData
% set(handles.InputData,'enable','on');
% open standard dialog box for retrieving files
[filename, pathname, filterindex] = uigetfile( ...
{'*.txt','TXT-files (*.txt)'; ...
'*.mat','MAT-files (*.mat)'; ...
'*.*', 'All Files (*.*)'}, ...
'Pick a file');
if filterindex == 0
% Illuminate if the data importing is canceled
% set(handles.InputData,'String','');
ud.fn = filename;
set(handles.FFTPlatForm,'UserData',ud);
handles.str=get(handles.Notes,'String');
handles.str=[handles.str;{'->> Notes: Data importing has been canceled!!!'}];
set(handles.Notes,'String',handles.str);
else
% Check the existence of the data
[fid msg] = fopen(filename,'r');
% If the data is not exist
if fid == -1
str1 = '->> Error: ';
str2 = msg;
str3 = 'Please insure your input data name is correct';
handles.str=get(handles.Notes,'String');
handles.str=[handles.str;str1;str2;str3];
set(handles.Notes,'String',handles.str);
% Open the require interface
require;
% If the data exist
else
fclose(fid);
% Display the data name in the edit window
set(handles.InputData,'String',filename);
ud.filename = filename;
set(handles.FFTPlatForm,'UserData',ud);
% Display the data name in the state frame
str1 = '->> The data to be processed is: ';
str2 = get(handles.InputData,'String');
str2 = filename;
str = [str1,str2];
set(handles.Notes,'ForegroundColor','black');
handles.str=get(handles.Notes,'String');
handles.str=[handles.str;str];
set(handles.Notes,'String',handles.str);
end
end
% flag=get(handles.InputData,'String');
% if ~isempty(flag)
% set(handles.ParametersSetting,'Enable','on');
% end
set(handles.ParametersSetting,'Enable','on');
% --- Executes during object creation, after setting all properties.
function ImportData_CreateFcn(hObject, eventdata, handles)
% hObject handle to ImportData (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes on button press in ParametersSetting.
function ParametersSetting_Callback(hObject, eventdata, handles)
% hObject handle to ParametersSetting (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
ParamSetting;
ud.hdl = handles;
ud.ed = eventdata;
ud.h = hObject;
ud.str=get(handles.Notes,'String');
set(handles.FFTPlatForm,'UserData',ud);
% --- Executes during object creation, after setting all properties.
function ParametersSetting_CreateFcn(hObject, eventdata, handles)
% hObject handle to ParametersSetting (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes on button press in WindowSelection.
function WindowSelection_Callback(hObject, eventdata, handles)
% hObject handle to WindowSelection (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in Apply.
function Apply_Callback(hObject, eventdata, handles)
% hObject handle to Apply (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of Apply
ud=get(handles.FFTPlatForm,'UserData');
% Get the input data
filename = get(handles.InputData,'String');
% Convert the binary data into float
% Input the data
BDataI = importdata(filename);
% Get the parameters
row_start = ud.RowStart;
row_end = ud.RowEnd;
col_start = ud.ColumnStart;
col_end = ud.ColumnEnd;
Fs=ud.Fs;
BDataI = BDataI(row_start:row_end,col_start:col_end);
% Notes in the state frame
str='->> The data type converting from binary to float has been done.';
handles.str=get(handles.Notes,'String');
handles.str=[handles.str;str];
set(handles.Notes,'String',handles.str);
% Reverseal operation selection
% Get the NeedReversal Selection information
valR = ud.valR;
% If the input data need not to be reversal
if valR == 1
BData = BDataI;
% If the input data need to be reversal
else
BData = fliplr(BDataI);
end
% Symbol bit operation selection
% Get the Symbol Bit Selection information
valS = ud.valS;
% If the input data is with symbol bit
if valS == 1
FData = bin2float(BData);
% If the input data is without symbol bit
else
FData = bi2de(BData(:,1:end),'left-msb');
end
% Transfer the float data to the userdata
ud.FData = FData;
ud.Fs=Fs;
set(handles.FFTPlatForm,'UserData',ud);
N=8;
offset=0;
SData=my_scatterplot(FData,N,offset);
ud.SData=SData;
set(handles.FFTPlatForm,'UserData',ud);
% FFT caculating
L = length(FData);
val = get(handles.WindowSelection,'Value');
switch val
case 1,
win = hamming(L);
case 2,
beta = 0.5;
win = kaiser(L,beta);
case 3,
win = hann(L);
case 4,
win = gausswin(L);
case 5,
win = blackman(L);
end
Wd = win;
ud.Wd = Wd;
set(handles.FFTPlatForm,'UserData',ud);
[Power,f] = fftpower(win.*FData,1,length(FData),Fs);
dBPower = 20*log10(Power);
[val,pos] = max(dBPower);
Power = dBPower - val;
% Transfer the FFT data to the userdata
ud.PData = Power;
ud.f = f;
set(handles.FFTPlatForm,'UserData',ud);
str1 = {'Time Domain Figure'};
str2 = {'Scatter'};
str3 = {'Eyediagram'};
str4 = {'FFT Power Figure'};
str5 = {'Envelope'};
str = [str1;str2;str3;str4;str5];
set(handles.VariableList,'String',str);
function Notes_Callback(hObject, eventdata, handles)
% hObject handle to Notes (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Notes as text
% str2double(get(hObject,'String')) returns contents of Notes as a double
% --- Executes during object creation, after setting all properties.
function Notes_CreateFcn(hObject, eventdata, handles)
% hObject handle to Notes (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in XAuto.
function XAuto_Callback(hObject, eventdata, handles)
% hObject handle to XAuto (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of XAuto
%
p=get(handles.Figure,'UserData');
ud = get(handles.FFTPlatForm,'UserData');
TData = ud.FData;
Fs = ud.Fs;
if p==1
val = get(handles.XAuto,'Value');
if val == 1
xmin = 0;
xmax = (length(TData)-1)/Fs;
set(handles.Figure,'XLim',[xmin xmax]);
set(handles.XMin,'String',num2str(xmin));
set(handles.XMax,'String',num2str(xmax));
else
XMin_Callback;
XMax_Callback;
end
% Set the Auto Parameter Enable on
set(handles.XAuto,'Enable','off');
else
if p==2
val = get(handles.XAuto,'Value');
if val == 1
xmin = -Fs/2;
xmax = Fs/2;
set(handles.Figure,'XLim',[xmin xmax]);
set(handles.XMin,'String',num2str(xmin));
set(handles.XMax,'String',num2str(xmax));
else
XMin_Callback;
XMax_Callback;
end
% Set the Auto Parameter Enable on
set(handles.XAuto,'Enable','off');
end
if p==3
val = get(handles.XAuto,'Value');
if val == 1
xmin = -Fs/2;
xmax = Fs/2;
set(handles.Figure,'XLim',[xmin xmax]);
set(handles.XMin,'String',num2str(xmin));
set(handles.XMax,'String',num2str(xmax));
else
XMin_Callback;
XMax_Callback;
end
% Set the Auto Parameter Enable on
set(handles.XAuto,'Enable','off');
end
end
% Set the Auto Parameter Enable on
set(handles.XAuto,'Enable','off');
function XMin_Callback(hObject, eventdata, handles)
% hObject handle to XMin (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of XMin as text
% str2double(get(hObject,'String')) returns contents of XMin as a
% double
xmin = str2double(get(handles.XMin,'String'));
x = get(handles.Figure,'XLim');
xmax = x(2);
set(handles.Figure,'XLim',[xmin xmax]);
set(handles.XAuto,'Value',0);
% Set the Auto Parameter Enable on
set(handles.XAuto,'Enable','on');
% --- Executes during object creation, after setting all properties.
function XMin_CreateFcn(hObject, eventdata, handles)
% hObject handle to XMin (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function XMax_Callback(hObject, eventdata, handles)
% hObject handle to XMax (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of XMax as text
% str2double(get(hObject,'String')) returns contents of XMax as a double
xmax = str2double(get(handles.XMax,'String'));
x = get(handles.Figure,'XLim');
xmin = x(1);
set(handles.Figure,'XLim',[xmin xmax]);
set(handles.XAuto,'Value',0);
% Set the Auto Parameter Enable on
set(handles.XAuto,'Enable','on');
% --- Executes during object creation, after setting all properties.
function XMax_CreateFcn(hObject, eventdata, handles)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -