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

📄 component_window_launcher.m

📁 此代码仿真了一个语音输入输出系统
💻 M
📖 第 1 页 / 共 4 页
字号:
                'callback', @spread_factor_cb);
            
            % Walsh Code label.
            walsh_field_label = uicontrol(spread,...
                'style', 'text',...
                'fontsize', walsh_field_label_fontsize,...
                'foregroundcolor', 'blue',...
                'backgroundcolor', [.8 .8 .8],... % same gray as GUI background
                'horizontalalignment', 'center',...
                'string', 'The current Walsh Code is (cursor down if all bits do not appear):',...
                'units', 'normalized',...
                'position', walsh_field_label_dims); % just above the Walsh Code field
            
            % Generated Walsh Code (updated everytime a Walsh Code is generated).
            global walsh_field;
            walsh_field = uicontrol(spread,...
                'style', 'edit',...
                'fontsize', walsh_field_fontsize,...
                'horizontalalignment', 'center',...
                'max', 4,... % try this to get multiple line support
                'min', 1,...
                'string', num2str(walsh'),... % Walsh Code (the first time it will be one of two possible 2-bit Walsh Codes)
                'units', 'normalized',...
                'position', walsh_field_dims );
            
            % Play input signal pushbutton.
            play_input = uicontrol(spread,...
                'style', 'pushbutton',...
                'string', 'Play Input',...
                'foregroundcolor', 'black',...
                'fontsize', play_input_fontsize,...
                'units', 'normalized',...
                'position', play_input_dims,...
                'callback', @play_input_cb);
            
            % Play spread input signal pushbutton.
            play_spread = uicontrol(spread,...
                'style', 'pushbutton',...
                'string', 'Play Spread Input',...
                'foregroundcolor', 'black',...
                'fontsize', play_spread_fontsize,...
                'units', 'normalized',...
                'position', play_spread_dims,...
                'callback', @play_spread_cb,...
                'tooltipstring', 'Click this button to play the spread input signal');
            
            % Stop spread input signal pushbutton.
            stop_spread = uicontrol(spread,...
                'style', 'pushbutton',...
                'string', 'Stop Spread Input',...
                'foregroundcolor', 'black',...
                'fontsize', stop_spread_fontsize,...
                'units', 'normalized',...
                'position', stop_spread_dims,...
                'callback', @stop_spread_cb,...
                'tooltipstring', 'Click this button to stop the spread input signal''s playback at any time');
            
            % Create Spread instructions window.
            spread_instructions = figure('position', spread_instructions_dims,...
                'menubar', 'none',...
                'numbertitle', 'off',...
                'resize', 'off',...
                'WindowButtonDownFcn', 'global spread_input_player; stop(spread_input_player);',... % stop spread playback
                'name', 'How Spreading Works');
            
            % Add Spread instructions.
            spread_instructions_txt = uicontrol(spread_instructions,...
                'style', 'text',...
                'fontsize', spread_instructions_txt_fontsize,...
                'foregroundcolor', [.5 0 0],...
                'backgroundcolor', [.8 .8 .8],... % same gray as GUI background
                'horizontalalignment', 'center',...
                'string', spread_string,...
                'units', 'normalized',...
                'position', spread_instructions_txt_dims);
            
        case 'adc_pb'
            % Create ADC window.
            adc = figure('position', adc_dims,...
            'menubar', 'none',...
            'numbertitle', 'off',...
            'resize', 'off',...
            'WindowButtonDownFcn', 'global spread_input_player; stop(spread_input_player);',... % stop spread playback
            'name', '3. Analog to Digital Conversion');
        
            % Add the first block of ADC text.
            adc_text_1 = uicontrol(adc,...
                'style', 'text',...
                'fontsize', adc_text_fontsize,...
                'foregroundcolor', [.5 0 0],...
                'backgroundcolor', [.8 .8 .8],... % same gray as GUI background
                'horizontalalignment', 'center',...
                'string', adc_string_1,...
                'units', 'normalized',...
                'position', adc_text_1_dims);
            
            % Add the math ADC block (use a larger font and different color text).
            adc_math_text = uicontrol(adc,...
                'style', 'text',...
                'fontsize', adc_text_fontsize + 3,...
                'foregroundcolor', 'black',...
                'backgroundcolor', [.8 .8 .8],... % same gray as GUI background
                'horizontalalignment', 'center',...
                'string', adc_math_string,...
                'units', 'normalized',...
                'position', adc_math_text_dims);
            
            % Add the second block of ADC text.
            adc_text_2 = uicontrol(adc,...
                'style', 'text',...
                'fontsize', adc_text_fontsize,...
                'foregroundcolor', [.5 0 0],...
                'backgroundcolor', [.8 .8 .8],... % same gray as GUI background
                'horizontalalignment', 'center',...
                'string', adc_string_2,...
                'units', 'normalized',...
                'position', adc_text_2_dims);
            
        case 'bpsk_pb'
            % Create BPSK window.
            bpsk = figure('position', bpsk_dims,...
                'menubar', 'none',...
                'numbertitle', 'off',...
                'resize', 'off',...
                'WindowButtonDownFcn', 'global spread_input_player; stop(spread_input_player);',... % stop spread playback
                'name', '4. Binary Phase Shift Keying');
            
            % Create axes for the first five cycles of the regular sinusoid (carrier) 
            % and BPSK carrier and plot.
            axes('position', bpsk_axes_1_dims, 'box', 'on');
            plot(sinusoid_data(:, 1:201), 'black');
            axis([0 201 -1 1]);
            title('First Five Cycles of the Sinusoidal Carrier');
            axes('position', bpsk_axes_2_dims, 'box', 'on');
            plot(carrier(:, 1:201), 'blue');
            axis([0 201 -1 1]);
            title('First Five Cycles of the Binary Phase Shift Keyed Sinusoidal Carrier');
            
            % Label the box that contains the first five bits of the user's input signal.
            bit_label = uicontrol(bpsk,...
                'style', 'text',...
                'fontsize', bit_label_fontsize,...
                'foregroundcolor', 'blue',...
                'backgroundcolor', [.8 .8 .8],... % same gray as GUI background
                'horizontalalignment', 'center',...
                'string', 'The first five bits of your input signal are:',...
                'units', 'normalized',...
                'position', bit_label_dims);
            
            % Display the first five bits of the user's input signal.
            first_five_bits = uicontrol(bpsk,...
                'style', 'edit',...
                'fontsize', first_five_bits_fontsize,...
                'foregroundcolor', 'black',...
                'horizontalalignment', 'center',...
                'string', num2str(bin_sequence(1:5, :)'),...
                'units', 'normalized',...
                'position', first_five_bits_dims);
            
            % BPSK text.
            bpsk_text = uicontrol(bpsk,...
                'style', 'text',...
                'fontsize', bpsk_text_fontsize,...
                'foregroundcolor', [.5 0 0],...
                'backgroundcolor', [.8 .8 .8],... % same gray as GUI background
                'horizontalalignment', 'center',...
                'string', bpsk_string,...
                'units', 'normalized',...
                'position', bpsk_text_dims);
            
        case 'srrc_1_pb'
            % Create SRRC filter #1 window.
            srrc_1 = figure('position', srrc_1_dims,...
                'menubar', 'none',...
                'numbertitle', 'off',...
                'resize', 'off',...
                'WindowButtonDownFcn', 'global spread_input_player; stop(spread_input_player);',... % stop spread playback
                'name', '5. Square Root Raised Cosine Filter #1');
            
            % Create axes for the first five cycles of the BPSK carrier and the output of the
            % transmitter's SRRC filter and plot.
            axes('position', srrc_1_axes_1_dims, 'box', 'on');
            plot(carrier(:, 1:201), 'blue');
            axis([0 201 -1 1]);
            title('First Five Cycles of the Binary Phase Shift Keyed Sinusoidal Carrier');
            axes('position', srrc_1_axes_2_dims, 'box', 'on');
            plot(trans_carrier_filtered(1:410, :), 'blue');
            axis([0 410 -1 1]);
            title('The Transmitter''s SRRC Filter Output');
            
            % SRRC #1 text.
            srrc_1_text = uicontrol(srrc_1,...
                'style', 'text',...
                'fontsize', srrc_1_text_fontsize,...
                'foregroundcolor', [.5 0 0],...
                'backgroundcolor', [.8 .8 .8],... % same gray as GUI background
                'horizontalalignment', 'center',...
                'string', srrc_1_string,...
                'units', 'normalized',...
                'position', srrc_1_text_dims);
            
        case 'srrc_2_pb'
            % Create SRRC filter #2 window.
            srrc_2 = figure('position', srrc_2_dims,...
                'menubar', 'none',...
                'numbertitle', 'off',...
                'resize', 'off',...
                'WindowButtonDownFcn', 'global spread_input_player; stop(spread_input_player);',... % stop spread playback
                'name', '6. Square Root Raised Cosine Filter #2');
            
            % Create axes for the first five cycles of the output of the transmitter's
            % SRRC filter and the first five cycles of the output of the receiver's and plot.
            axes('position', srrc_2_axes_1, 'box', 'on');
            plot(trans_carrier_filtered(1:410, :), 'blue');
            axis([0 410 -1 1]);
            title('The Transmitter''s SRRC Filter Output (the received signal)');
            axes('position', srrc_2_axes_2, 'box', 'on');
            plot(rec_carrier_filtered(1:414, :), 'magenta');
            axis([0 414 -1 1]);
            title('The Receiver''s SRRC Filter Output');
            
            % SRRC #2 text.
            srrc_2_text = uicontrol(srrc_2,...
                'style', 'text',...
                'fontsize', srrc_2_text_fontsize,...
                'foregroundcolor', [.5 0 0],...
                'backgroundcolor', [.8 .8 .8],... % same gray as GUI background
                'horizontalalignment', 'center',...
                'string', srrc_2_string,...
                'units', 'normalized',...
                'position', srrc_2_text_dims);
            
        case 'debpsk_pb'
            % Create de-BPSK window.
            debpsk = figure('position', debpsk_dims,...
                'menubar', 'none',...
                'numbertitle', 'off',...
                'resize', 'off',...
                'WindowButtonDownFcn', 'global spread_input_player; stop(spread_input_player);',... % stop spread playback
                'name', '7. de-Binary Phase Shift Keying');
            
            % Create axes for the first five cycles of the trimmed/received
            % BPSK signal, the reference cycle used for correlation, and the 
            % product of the reference cycle and the first cycle of the filtered signal.
            axes('position', debpsk_axes_1, 'box', 'on');
            plot(rec_filtered_trimmed(1:401, :), 'magenta');
            axis([0 401 -1 1]);
            title('The Receiver''s SRRC Filter Output (trimmed to remove spurious filter data)');
            axes('position', debpsk_axes_2, 'box', 'on');
            plot(ref_cycle, 'black');
            axis([1 41 -1 1]);
            title('The Correlation Reference Cycle');
            axes('position', debpsk_axes_3, 'box', 'on');
            plot(first_product, 'black');
            axis([1 41 -1 1]);
            title('The Product of the Filter Output''s First Cycle and the Correlation Reference Cycle ');
            
            % Label the box that contains the first five bits of the user's received
            % input signal.
            rec_bit_label = uicontrol(debpsk,...
                'style', 'text',...
                'fontsize', rec_bit_label_fontsize,...
                'foregroundcolor', 'blue',...
                'backgroundcolor', [.8 .8 .8],... % same gray as GUI background
                'horizontalalignment', 'center',...
                'string', 'The first five RECEIVED bits of your input signal are:',...
                'units', 'normalized',...
                'position', rec_bit_label_dims);
            
            % Display the first five bits of the user's received input signal.
            first_five_rec_bits = uicontrol(debpsk,...
                'style', 'edit',...
                'fontsize', first_five_bits_rec_fontsize,...
                'foregroundcolor', 'black',...
                'horizontalalignment', 'center',...
                'string', num2str(bin_sequence_received(1:5, :)'),...
                'units', 'normalized',...
                'position', first_five_bits_rec_dims);
            
            % Create de-BPSK text window.
            debpsk_instructions = figure('position', debpsk_instructions_dims,...
                'menubar', 'none',...
                'numbertitle', 'off',...
                'resize', 'off',...
                'WindowButtonDownFcn', 'global spread_input_player; stop(spread_input_player);',... % stop spread playback
                'name', 'The de-Binary Phase Shift Keying Algorithm');
            
            % de-BPSK text.
            debpsk_instructions_txt = uicontrol(debpsk_instructions,...
                'style', 'text',...
                'fontsize', debpsk_instructions_txt_fontsize,...
                'foregroundcolor', [.5 0 0],...
                'backgroundcolor', [.8 .8 .8],... % same gray as GUI background
                'horizontalalignment', 'center',...
                'string', debpsk_string,...
                'units', 'normalized',...
                'position', debpsk_instructions_txt_dims);
            
        case 'dac_pb'

⌨️ 快捷键说明

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