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

📄 txtester_export.m

📁 一个仿真测试4FSK信号的matlab环境GUI程序。可以查看基带IQ波形、眼图、星座图。并可以仿真高斯白噪声、瑞利衰减对信号的影响。
💻 M
📖 第 1 页 / 共 5 页
字号:
function varargout = TxTester_export(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @TxTester_export_OpeningFcn, ...
                   'gui_OutputFcn',  @TxTester_export_OutputFcn, ...
                   'gui_LayoutFcn',  @TxTester_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 TxTester_export is made visible.
function TxTester_export_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
handles.CurrentPath = pwd;
addpath(handles.CurrentPath);

handles.str = {'           Transmitter basebande Test v1.0'; ...
               '               for DMR CP4FSK modulation.'; ...
               '         written by zhengliangde, hyt, CO., LTD.'; ...
               '               Contact: harlemon@126.com'};

handles.str = [handles.str; {'->> Starting TxTester Program...'}];
set(handles.edt_Process, 'string', handles.str);

mainfig = findobj(allchild(0),'tag','TxTester');
if strcmp(get(mainfig,'visible'),'off'),
    h=waitbar(0,'TxTester','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

axes(handles.axes_main);
title('Received signal');
ylabel('Amplitude');
xlabel('Time (s)');

set(handles.txt_CurrentDate,'string',['Current Date: ',date]);

handles.str = [handles.str; {'->> Starting TxTester Program... Done!'}; ...
    {'->> Ready.'}];
set(handles.edt_Process, 'string', handles.str);

% Update handles structure
guidata(hObject, handles);

clc;
[m,n] = size(handles.str);
for i = 1:m
    disp(handles.str{i});
end
% UIWAIT makes TxTester_export wait for user response (see UIRESUME)
% uiwait(handles.TxTester_export);


% --- Outputs from this function are returned to the command line.
function varargout = TxTester_export_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;


function edt_Process_Callback(hObject, eventdata, handles)
% hObject    handle to edt_Process (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 edt_Process as text
%        str2double(get(hObject,'String')) returns contents of edt_Process as a double


% --- Executes during object creation, after setting all properties.
function edt_Process_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edt_Process (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 selection change in List_Signal.
function List_Signal_Callback(hObject, eventdata, handles)
% hObject    handle to List_Signal (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns List_Signal contents as cell array
%        contents{get(hObject,'Value')} returns selected item from List_Signal


% --- Executes during object creation, after setting all properties.
function List_Signal_CreateFcn(hObject, eventdata, handles)
% hObject    handle to List_Signal (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox 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 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_Fd_Callback(hObject, eventdata, handles)
value = str2num(get(handles.edt_Mod_Fd,'string'));
if isempty(value)
    msgbox('Invalid value in the ''Fd'' Edit field. Check again!', ...
        'ERROR','ERROR');
    return
else
    if value<0 || value/100 ~= fix(value/100)
        msgbox('Invalid Fd. See your Transmitter setting.', ...
            'ERROR', 'ERROR');
        return
    end
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

% =======================================================================
function edt_Mod_Index_Callback(hObject, eventdata, handles)
value = str2num(get(handles.edt_Mod_Index,'string'));
if isempty(value)
    msgbox('Invalid value in the ''Index'' Edit field. Check again!',...
        'ERROR','ERROR');
    return
else
    if value<0 || value>1
        msgbox('Invalid Index. See you Transmitter setting.', ...
            'ERROR', 'ERROR');
        return
    end
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('Invalid number in the ''nSamp'' Edit field. Check again!', ...
        'ERROR','ERROR');
    return
else
    if value<0 || value~=fix(value)
        msgbox('Invalid nSamp, see your Transmitter settings.', ...
            'ERROR', 'ERROR');
        return
    end
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_Type.
function pop_RRC_Type_Callback(hObject, eventdata, handles)

% --- Executes during object creation, after setting all properties.
function pop_RRC_Type_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('Invalid value in the ''Order'' Edit field. Check again!', ...
        'ERROR', 'ERROR');
    return
else
    if value<1 || value ~= fix(value)
        msgbox('Invalid filter order. Must be a integer','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_RRC_OverSamp_Callback(hObject, eventdata, handles)
value = str2num(get(handles.edt_RRC_OverSamp,'string'));
if isempty(value)
    msgbox('Invalid value in the ''OverSamp'' Edit field. Check again!', ...
        'ERROR','ERROR');
    return
else
    if value<0 || value~=fix(value)
        msgbox('Invalid OverSamp, see your Transmitter settings.', ...
            'ERROR', 'ERROR');
        return
    end
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('Invalid value in the ''RollOff'' Edit field. Check again!', ...
        'ERROR', 'ERROR');
    return
else
    if value<0 || value>1
        msgbox('Invalid filter RollOff factor!', 'ERROR', 'ERROR');
        return
    end
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

% ==============================================================
% --- Executes on button press in btn_Plot.
function btn_Plot_Callback(hObject, eventdata, handles)
set(handles.output, 'Pointer', 'watch');
data = handles.data;
param = GetParam(handles);
val = get(handles.list_Signal, 'value');
axes(handles.axes_main);
switch val
    case 1
        t = [0:length(data.yFading)-1]'/(4800*param.mod.nSamp*param.rrc.OverSamp);
        plot(t, real(data.yFading), 'b-');
        maxLen = length(data.yFading);
        strTitle = 'In-Phase Signal(Imported)';
        strxLabel = 'Time(s)';
        stryLabel = 'Amplitude';
    case 2
        t = [0:length(data.yFading)-1]'/(4800*param.mod.nSamp*param.rrc.OverSamp);
        plot(t, imag(data.yFading), 'r-');
        maxLen = length(data.yFading);
        strTitle = 'Quadrature-Phase Signal(Imported)';
        strxLabel = 'Time(s)';
        stryLabel = 'Amplitude';
    case 3
        plot(real(data.yFading), imag(data.yFading), 'c-');
        maxLen = length(data.yFading);
        strTitle = 'I/Q Phase Plot(Imported)';
        strxLabel = 'In-Phase Signal';
        stryLabel = 'Quadrature-Phase Signal';
    case 5
        t = [0:length(data.yDown)-1]'/(4800*param.mod.nSamp);
        maxLen = length(data.yDown);
        plot(t, real(data.yDown), 'b-');
        strTitle = 'In-Phase Signal(Filtered)';
        strxLabel = 'Time(s)';
        stryLabel = 'Amplitude';
    case 6
        t = [0:length(data.yDown)-1]'/(4800*param.mod.nSamp);
        maxLen = length(data.yDown);
        plot(t, imag(data.yDown), 'r-');
        strTitle = 'Quadrature-Phase Signal(Filtered)';
        strxLabel = 'Time(s)';
        stryLabel = 'Amplitude';
    case 7
        maxLen = length(data.yDown);
        plot(real(data.yDown), imag(data.yDown), 'c-');
        strTitle = 'I/Q Phase Plot(after filter)';
        strxLabel = 'In-Phase Signal';
        stryLabel = 'Quadrature-Phase Signal';
    case 9
        t = [0:length(data.z)-1]'/4800;
        maxLen = length(data.z);
        stem(t, data.z, 'm.');
        strTitle = 'Demodulated Signal';
        strxLabel = 'Time (s)';
        stryLabel = 'Amplitude';
        axis([0 max(t) -5 5]);
    case 11
        maxLen = length(data.rrcfltcoef);
        plot(data.rrcfltcoef, 'r.');
        strTitle = 'Impulse Response(RRC)';
        strxLabel = 'Sample';
        stryLabel = 'Amplitude';
    otherwise
        return
        
end
SetAxes(handles,strTitle,strxLabel,stryLabel);
SetSlider(handles, maxLen);
set(handles.output, 'Pointer', 'arrow');

% =================================================================
function SetAxes(handles, strtitle, strxlabel, strylabel, strzlabel)
if nargin<5
    strzlabel = [];
end
set(handles.axes_main, 'XGrid', 'on');
set(handles.axes_main, 'YGrid', 'on');
set(handles.axes_main, 'XMinorTick', 'on');
set(handles.axes_main, 'YMinorTick', 'on');
title(strtitle);
xlabel(strxlabel);
ylabel(strylabel);
if ~isempty(strzlabel)
    set(handles.axes_main, 'ZGrid', 'on');
    set(handles.axes_main, 'ZMinorTick', 'on');
    zlabel(strzlabel);
end

% ================================================================
function SetSlider(handles,maxLen)
set([handles.slider_AxesAdjust_From, ...
    handles.slider_AxesAdjust_To], 'max', maxLen);
set([handles.slider_AxesAdjust_From, ...
    handles.slider_AxesAdjust_To], 'min', 0);
set(handles.slider_AxesAdjust_From, 'value', 1);
set(handles.slider_AxesAdjust_To, 'value', maxLen);
set(handles.edt_PlotNum_From, 'string', num2str(1));
set(handles.edt_PlotNum_To, 'string', num2str(maxLen));
set([handles.slider_AxesAdjust_From, handles.slider_AxesAdjust_To], ...
    'SliderStep', [8/maxLen,80/maxLen])

% ===================================================================
% --- Executes on button press in btn_Plot3.
function btn_Plot3_Callback(hObject, eventdata, handles)

⌨️ 快捷键说明

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