?? fftplatform.asv
字號:
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 30-Aug-2007 20:27:12
% 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);
% --- Executes on button press in TimeDomainFigurePlot.
function TimeDomainFigurePlot_Callback(hObject, eventdata, handles)
% hObject handle to TimeDomainFigurePlot (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 TimeDomainFigurePlot
% Get the float data and the sample frequency
ud = get(handles.FFTPlatForm,'UserData');
TData = ud.FData;
Fs = ud.Fs;
% Plot the time domain figure
t = [0:(length(TData)-1)]/Fs;
axes(handles.Figure)
stairs(t,TData);
title('Time Domain Figure');
xlabel('t/(ms)')
ylabel('Magnitude')
zoom on;grid on;axis tight;hold off;% creat imag plot
% Set the Notes frame
set(handles.Notes,'ForegroundColor','black');
handles.str=get(handles.Notes,'String');
str = '->> Time domain figure ploting has been done.';
handles.str=[handles.str;str];
set(handles.Notes,'String',handles.str);
% Set the axes control frame
xmin = num2str(0);
xmax = num2str(((length(TData)-1)/Fs));
set(handles.XMin,'String',xmin);
set(handles.XMax,'String',xmax);
ymin = num2str(min(TData));
ymax = num2str(max(TData));
set(handles.YMin,'String',ymin);
set(handles.YMax,'String',ymax);
% Set the Auto Paremeter Value
set(handles.XAuto,'Value',1);
set(handles.YAuto,'Value',1);
set(handles.Plot,'UserData',1);
% --- Executes on button press in ScatterPlot.
function ScatterPlot_Callback(hObject, eventdata, handles)
% hObject handle to ScatterPlot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get the float data and the sample frequency
ud = get(handles.FFTPlatForm,'UserData');
SData = ud.SData;
plotstring='b.';
maxAll = max(max(abs(SData)));
[len_SD, wid_SD]=size(SData);
if wid_SD == 1
axes(handles.Figure)
plot(SData, zeros(1,len_SD), plotstring);
elseif wid_SD == 2
axes(handles.Plot)
plot(SData(:,1), SData(:,2), plotstring);
end
axis([-eps eps -eps eps]);
axo = axis;
limFact = 1.07;
limits = max(max(abs(axo)),maxAll*limFact);
axis equal;
axis([-limits limits -limits limits]);
ylabel('Quadrature')
xlabel('In-Phase')
title('Scatter plot')
zoom on;grid on;axis tight;hold off;% creat imag plot
% --- Executes on button press in EyeDiagramPlot.
function EyeDiagramPlot_Callback(hObject, eventdata, handles)
% hObject handle to EyeDiagramPlot (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 IQPhaseErrorCaculation.
function IQPhaseErrorCaculation_Callback(hObject, eventdata, handles)
% hObject handle to IQPhaseErrorCaculation (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 SNRCaculation.
function SNRCaculation_Callback(hObject, eventdata, handles)
% hObject handle to SNRCaculation (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 FFTPowerFigurePlot.
function FFTPowerFigurePlot_Callback(hObject, eventdata, handles)
% hObject handle to FFTPowerFigurePlot (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 FFTPowerFigurePlot
% Get the FFT data and the f factor
ud = get(handles.FFTPlatForm,'UserData');
Power = ud.PData;
Fs = ud.Fs;
f = ud.f;
% Plot the FFT Power figure
axes(handles.Figure)
plot(f,Power);
grid on
title('FFT Power Magnitude Spectrum')
xlabel('f/(kHz)')
ylabel('Magnitude in dBm')
zoom on;grid on;axis tight;hold off;% creat imag plot
set(handles.Notes,'ForegroundColor','black');
handles.str=get(handles.Notes,'String');
str = '->> FFT Power figure ploting has been done.';
handles.str=[handles.str;str];
set(handles.Notes,'String',handles.str);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -