function varargout = ReceiverTest_export(varargin)
% RECEIVERTEST_EXPORT M-file for ReceiverTest_export.fig
% Begin initialization code
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @ReceiverTest_export_OpeningFcn, ...
'gui_OutputFcn', @ReceiverTest_export_OutputFcn, ...
'gui_LayoutFcn', @ReceiverTest_export_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 ReceiverTest_export is made visible.
function ReceiverTest_export_OpeningFcn(hObject, eventdata, handles, varargin)
% wati bar.
mainfig = findobj(allchild(0),'tag','ReceiverTest');
if strcmp(get(mainfig,'visible'),'off'),
h=waitbar(0,'ReceiverTest','Name','Starting Program...');
pause(0.1);
for i=1:100
waitbar(i/100,h,['Percentage:',num2str(i),'% '],h);
end
close(h);
pause(0.1)
else
figure(mainfig);
return
end
handles.output = hObject;
% -----------------
handles.param.src.BitNum = 9600;
handles.param.src.InitSeed = 12345;
handles.param.mod.Fd = 4800;
%handles.param.mod.FrqDev = 1296;
handles.param.mod.nSamp = 8;
handles.param.mod.Index = 0.27;
handles.param.rrc.Order = 64;
handles.param.rrc.OverSamp = 16;
handles.param.rrc.Delay = 2;
handles.param.rrc.RollOf = 0.2;
handles.param.awgn.EbNo = 10;
handles.param.fading.Td = 1/(4800*handles.param.mod.nSamp*handles.param.rrc.OverSamp);
handles.param.fading.frqShift = 40;
handles.param.fading.DelayVec = [0 2e-6];
handles.param.fading.GainVec = [0 -3];
% -----------------
handles.CurrentPath = pwd;
addpath(handles.CurrentPath);
% Update handles structure
guidata(hObject, handles);
set(handles.txt_Date,'string',['Current Date: ',date]);
set(handles.txt_Status,'string','Status: Ready');
axes(handles.axes_Src);
title('Source Signal');xlabel('Number');ylabel('Amplitude');
axes(handles.axes_RRC);
title('Square Root Raised Cosine Filter-Impluse Response');
xlabel('Sample');ylabel('Amplitude');
% UIWAIT makes ReceiverTest_export wait for user response (see UIRESUME)
% uiwait(handles.ReceiverTest_export);
% --- Outputs from this function are returned to the command line.
function varargout = ReceiverTest_export_OutputFcn(hObject, eventdata, handles)
% Get default command line output from handles structure
varargout{1} = handles.output;
% =================================================================
function edt_Src_BitNum_Callback(hObject, eventdata, handles)
value = str2num(get(handles.edt_Src_BitNum,'string'));
if isempty(value)
msgbox('Get a invalid number in the ''BitNum'' Edit field. Check again!','ERROR','ERROR');
return
else
if fix(value/100) ~= value/100
msgbox('BitNum must be mutiple of 100.', 'ERROR', 'ERROR');
return
end
end
set(handles.btn_Apply, 'enable', 'on');
% --- Executes during object creation, after setting all properties.
function edt_Src_BitNum_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% ==================================================================
function edt_Src_InitSeed_Callback(hObject, eventdata, handles)
value = str2num(get(handles.edt_Src_InitSeed,'string'));
if isempty(value)
msgbox('Get a invalid number in the ''InitSeed'' Edit field. Check again!','ERROR','ERROR');
return
end
set(handles.btn_Apply, 'enable', 'on');
% --- Executes during object creation, after setting all properties.
function edt_Src_InitSeed_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% =================================================================
function edt_Mod_Fd_Callback(hObject, eventdata, handles)
value = str2num(get(handles.edt_Mod_Fd,'string'));
if isempty(value)
msgbox('Get a invalid number in the ''Fd'' Edit field. Check again!','ERROR','ERROR');
return
end
set(handles.btn_Apply, 'enable', 'on');
% --- Executes during object creation, after setting all properties.
function edt_Mod_Fd_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% =================================================================
% --- Executes on selection change in pop_Mod_Method.
function pop_Mod_Method_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function pop_Mod_Method_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% ================================================================
function edt_Mod_Index_Callback(hObject, eventdata, handles)
value = str2num(get(handles.edt_Mod_Index,'string'));
if isempty(value)
msgbox('Get a invalid number in the ''Index'' Edit field. Check again!','ERROR','ERROR');
return
end
set(handles.btn_Apply, 'enable', 'on');
% --- Executes during object creation, after setting all properties.
function edt_Mod_Index_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% ================================================================
function edt_Mod_nSamp_Callback(hObject, eventdata, handles)
value = str2num(get(handles.edt_Mod_nSamp,'string'));
if isempty(value)
msgbox('Get a invalid number in the ''nSamp'' Edit field. Check again!','ERROR','ERROR');
return
end
set(handles.btn_Apply, 'enable', 'on');
% --- Executes during object creation, after setting all properties.
function edt_Mod_nSamp_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% =================================================================
% --- Executes on selection change in pop_RRC.
function pop_RRC_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function pop_RRC_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% =================================================================
function edt_RRC_OverSamp_Callback(hObject, eventdata, handles)
value = str2num(get(handles.edt_RRC_OverSamp,'string'));
if isempty(value)
msgbox('Get a invalid number in the ''OverSamp'' Edit field. Check again!','ERROR','ERROR');
return
end
set(handles.btn_Apply, 'enable', 'on');
% --- Executes during object creation, after setting all properties.
function edt_RRC_OverSamp_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% =================================================================
function edt_RRC_RollOff_Callback(hObject, eventdata, handles)
value = str2num(get(handles.edt_RRC_RollOff,'string'));
if isempty(value) || value>1 || value<0
msgbox('Get a invalid number in the ''Delay'' Edit field. Check again!','ERROR','ERROR');
return
end
set(handles.btn_Apply, 'enable', 'on');
% --- Executes during object creation, after setting all properties.
function edt_RRC_RollOff_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% ==================================================================
function edt_RRC_Order_Callback(hObject, eventdata, handles)
value = str2num(get(handles.edt_RRC_Order,'string'));
if isempty(value)
msgbox('Get a invalid number in the ''Order'' Edit field. Check again!','ERROR','ERROR');
return
else
if value<1
msgbox('Filter order must great than one.','ERROR','ERROR');
return
end
end
set(handles.btn_Apply, 'enable', 'on');
% --- Executes during object creation, after setting all properties.
function edt_RRC_Order_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% =================================================================
function edt_AWGN_EbNo_Callback(hObject, eventdata, handles)
value = str2num(get(handles.edt_AWGN_EbNo,'string'));
if isempty(value)
msgbox('Get a invalid number in the ''EbNo'' Edit field. Check again!','ERROR','ERROR');
return
end
set(handles.btn_Apply, 'enable', 'on');
% --- Executes during object creation, after setting all properties.
function edt_AWGN_EbNo_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% ================================================================
function edt_Fading_FrqShift_Callback(hObject, eventdata, handles)
value = str2num(get(handles.edt_Fading_FrqShift,'string'));
if isempty(value)
msgbox('Get a invalid number in the ''Freq Shift'' Edit field. Check again!','ERROR','ERROR');
return
end
set(handles.btn_Apply, 'enable', 'on');
% --- Executes during object creation, after setting all properties.
function edt_Fading_FrqShift_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% ================================================================
function edt_Fading_DelayVec_Callback(hObject, eventdata, handles)
value = str2num(get(handles.edt_Fading_DelayVec,'string'));
if isempty(value)
msgbox('Get a invalid number in the ''Delay Vec'' Edit field. Check again!','ERROR','ERROR');
return
end
set(handles.btn_Apply, 'enable', 'on');
% --- Executes during object creation, after setting all properties.
function edt_Fading_DelayVec_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% ================================================================
% --- Executes on button press in chkb_AWGN.
function chkb_AWGN_Callback(hObject, eventdata, handles)
if get(handles.chkb_AWGN,'value')
set(handles.edt_AWGN_EbNo,'enable','on');
else
set(handles.edt_AWGN_EbNo,'enable','off');
end
set(handles.btn_Apply, 'enable', 'on');
% --- Executes on button press in chkb_Fading.
function chkb_Fading_Callback(hObject, eventdata, handles)
if get(handles.chkb_Fading,'value')
set([handles.edt_Fading_FrqShift, handles.edt_Fading_DelayVec, ...
handles.edt_Fading_GainVec], 'enable', 'on');
else
set([handles.edt_Fading_FrqShift, handles.edt_Fading_DelayVec, ...
handles.edt_Fading_GainVec], 'enable', 'off');
end
set(handles.btn_Apply, 'enable', 'on');
% ====================================================================
function edt_Fading_GainVec_Callback(hObject, eventdata, handles)
value = str2num(get(handles.edt_Fading_GainVec,'string'));
if isempty(value)
msgbox('Get a invalid number in the ''Gain Vec'' Edit field. Check again!','ERROR','ERROR');
return
end
set(handles.btn_Apply, 'enable', 'on');
% --- Executes during object creation, after setting all properties.
function edt_Fading_GainVec_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% =====================================================================
% --- Executes on button press in btn_LoadParam.
function btn_LoadParam_Callback(hObject, eventdata, handles)
set(handles.txt_Status, 'string', 'Status: Importing Parameters...');
pause(0.01);
path = strcat(handles.CurrentPath, '\Parameters\');
cd(path);
[FileName,PathName,FilterIndx] = ...
uigetfile({'*.mat','Mat-files(*.mat)';'*.*','All files(*.*)'},'Import Parameters');
if FilterIndx
load(FileName);
if exist('param','var')
SetParam(handles, param);
set(handles.txt_Status, 'string', 'Status: Importing Parameters... Done');
pause(0.01)
else
set(handles.txt_Status, 'string', ...
'Status: Importing Parameters... Failed, wrong format parameter');
pause(0.01);
end
else
set(handles.txt_Status, 'string', ...
'Status: Importing Parameters... Failed, user cancel!');
pause(0.01);
end
cd(handles.CurrentPath);
set(handles.btn_Apply, 'enable', 'on');
% --- Executes on button press in btn_SaveParam.
function btn_SaveParam_Callback(hObject, eventdata, handles)
set(handles.txt_Status, 'string', 'Status: Saving Parameters...');
pause(0.01)
param = GetParam(handles);
path = strcat(handles.CurrentPath, '\Parameters\');
cd(path);
[FileName,PathName,FilterIndx] = ...
uiputfile({'*.mat','Mat-files(*.mat)';'*.*','All files(*.*)'},'Save Parameters');
if FilterIndx
save(FileName, 'param');
set(handles.txt_Status, 'string', 'Status: Saving Parameters... Done');
pause(0.01)
else
set(handles.txt_Status, 'string', ...
'Status: Saving Parameters... Failed, user cancel!');
pause(0.01)
end
cd(handles.CurrentPath);
% --- Executes on button press in btn_SaveData.
function btn_SaveData_Callback(hObject, eventdata, handles)
set(handles.txt_Status, 'string', 'Status: Saving Data...');
pause(0.01);
y_Len = length(handles.data.yFading);
Data = [real(handles.data.yFading)'; imag(handles.data.yFading)'];
path = strcat(handles.CurrentPath, '\Data\');
cd(path);
[FileName,PathName,FilterIndx] = ...
uiputfile({'*.txt','text files(*.txt)';'*.*','All files(*.*)'},'Save Data');
if FilterIndx
fid = fopen(FileName, 'w');
hPro = waitbar(0,'Save Data','Name','Saving Data...');
pause(0.01);
interval = fix(y_Len/100);
for i = 1:100
fprintf(fid, '%6.5f\t%6.5f\n', Data(:,(i-1)*interval+1:i*interval));
waitbar(i/100, hPro, ['Percentage:',num2str(i),'% '], hPro);
end
fprintf(fid, '%6.5f\t%6.5f\n', Data(:,i*interval+1:y_Len));
close(hPro);
fclose(fid);
set(handles.txt_Status, 'string', 'Status: Saving Data... Done');
pause(0.01);
else
set(handles.txt_Status, 'string', ...
'Status: Saving Data... Failed, user cancel!');
pause(0.01)
end
cd(handles.CurrentPath);
% --- Executes on button press in btn_Apply.
function btn_Apply_Callback(hObject, eventdata, handles)
set(handles.txt_Status, 'string', 'Status: Collecting and Checking Parameters...');
set(handles.output, 'Pointer', 'watch');
pause(0.01);
param = GetParam(handles);