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

📄 line_code.m

📁 Simulation of digital baseband modulation,it is very good for the users to deepen their understandin
💻 M
📖 第 1 页 / 共 2 页
字号:
            axis([0 10 -1.5 1.5]);
        else
            if h(n+1)==0
                y=(t<n)-2*(t<n-0.5)+1*(t==n);
            else
                y=(t<n)-2*(t<n-0.5)-1*(t==n);
            end
            d=plot(t,y);title('Code MANCHESTER RZ');grid on;
            set(d,'LineWidth',2.5);
            hold on;
            axis([0 10 -1.5 1.5]);
        end
        n=n+1;
        end

end
%*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

guidata(hObject, handles);


% --- Executes on selection change in select_code.
function select_code_Callback(hObject, eventdata, handles)
% hObject    handle to select_code (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 select_code contents as cell array
%        contents{get(hObject,'Value')} returns selected item from select_code
a=str2double(get(handles.uno,'String'));
b=str2double(get(handles.dos,'String'));
c=str2double(get(handles.tres,'String'));
d=str2double(get(handles.cuatro,'String'));
e=str2double(get(handles.cinco,'String'));
f=str2double(get(handles.seis,'String'));
g=str2double(get(handles.siete,'String'));
h=str2double(get(handles.ocho,'String'));
i0=str2double(get(handles.nueve,'String'));
j0=str2double(get(handles.diez,'String'));

if (a~=0 & a~=1)
   errordlg('The value must be binary',' ERROR ');
   set(handles.uno,'String','X');
elseif (b~=0 & b~=1)
   errordlg('The value must be binary',' ERROR ');
   set(handles.dos,'String','X');
elseif (c~=0 & c~=1)
   errordlg('The value must be binary',' ERROR ');
   set(handles.tres,'String','X');
elseif (d~=0 & d~=1)
   errordlg('The value must be binary',' ERROR ');
   set(handles.cuatro,'String','X');
elseif (e~=0 & e~=1)
   errordlg('The value must be binary',' ERROR ');
   set(handles.cinco,'String','X');
elseif (f~=0 & f~=1)
   errordlg('The value must be binary',' ERROR ');
   set(handles.seis,'String','X');
elseif (g~=0 & g~=1)
   errordlg('The value must be binary',' ERROR ');
   set(handles.siete,'String','X');
elseif (h~=0 & h~=1)
   errordlg('The value must be binary',' ERROR ');
   set(handles.ocho,'String','X');
elseif (i0~=0 & i0~=1)
   errordlg('The value must be binary',' ERROR ');
   set(handles.nueve,'String','X');
elseif (j0~=0 & j0~=1)
   errordlg('The value must be binary',' ERROR ');
   set(handles.diez,'String','X');
end

handles.bits=[a,b,c,d,e,f,g,h,i0,j0];
handles.cod=get(hObject,'Value');
switch handles.cod
    case 1
        hold off;
        h=handles.bits;
        n=1;
        h(11)=1;
        while n<=10;
            t=n-1:0.001:n;
        if h(n) == 0
            if h(n+1)==0  
                y=(t>n);
            else
                y=(t==n);
            end
            d=plot(t,y);title('Code UNIPOLAR NRZ');grid on
            set(d,'LineWidth',2.5);
            hold on;
            axis([0 10 -1.5 1.5]);
        else
            if h(n+1)==0
                y=(t<n)-0*(t==n);
            else
                y=(t<n)+1*(t==n);
            end
            d=plot(t,y);title('Code UNIPOLAR NRZ');grid on;
            set(d,'LineWidth',2.5);
            hold on;
            axis([0 10 -1.5 1.5]);
        end
        n=n+1;
        end
    case 2
        hold off;
        h =handles.bits;
        n=1;
        h(11)=1;
        while n<=10;
            t=n-1:0.001:n;
        if h(n) == 0
            if h(n+1)==0  
                y=-(t<n)-(t==n);
            else
                y=-(t<n)+(t==n);
            end
            d=plot(t,y);title('Code POLAR NRZ');grid on
            set(d,'LineWidth',2.5);
            hold on;
            axis([0 10 -1.5 1.5]);
        else
            if h(n+1)==0
                y=(t<n)-1*(t==n);
            else
                y=(t<n)+1*(t==n);
            end
            d=plot(t,y);title('Code POLAR NRZ');grid on;
            set(d,'LineWidth',2.5);
            hold on;
            axis([0 10 -1.5 1.5]);
        end
        n=n+1;
        end
        
    case 3
        hold off;
        h =handles.bits;
        n=1;
        h(11)=1;
        while n<=10;
            t=n-1:0.001:n;
        %Graficaci髇 de los CEROS (0)
            if h(n) == 0
                if h(n+1)==0  
                    y=(t>n);
                else
                    y=(t==n);
                end
            d=plot(t,y);title('Code UNIPOLAR RZ');grid on
            set(d,'LineWidth',2.5);
            hold on;
            axis([0 10 -1.5 1.5]);
        %Graficaci髇 de los UNOS (1)
            else
            if h(n+1)==0
                y=(t<n-0.5);
            else
                y=(t<n-0.5)+1*(t==n);
            end
            d=plot(t,y);title('Code UNIPOLAR RZ');grid on;
            set(d,'LineWidth',2.5);
            hold on;
            axis([0 10 -1.5 1.5]);
            end
        n=n+1;
         
        end
        
    case 4
        hold off;
        h =handles.bits;
        n=1;
        h(11)=1;
        while n<=10;
            t=n-1:0.001:n;
        if h(n) == 0
            if h(n+1)==0  
                y=-(t<n-0.5)-(t==n);
            else
                y=-(t<n-0.5)+(t==n);
            end
            d=plot(t,y);title('Code BIPOLAR RZ');grid on
            set(d,'LineWidth',2.5);
            hold on;
            axis([0 10 -1.5 1.5]);
        else
            if h(n+1)==0
                y=(t<n-0.5)-1*(t==n);
            else
                 y=(t<n-0.5)+1*(t==n);
            end
            d=plot(t,y);title('Code BIPOLAR RZ');grid on;
            set(d,'LineWidth',2.5);
            hold on;
            axis([0 10 -1.5 1.5]);
        end
        n=n+1;
        end

    case 5
        hold off;
        h =handles.bits;
        n=1;
        h(11)=1;
        ami=-1;
        while n<=10;
            t=n-1:0.001:n;
        if h(n) == 0
            if h(n+1)==0  
                y=(t>n);
            else
                if ami==1
                    y=-(t==n);
                else
                    y=(t==n);
                end
            end
            d=plot(t,y);title('Code AMI NRZ');grid on
            set(d,'LineWidth',2.5);
            hold on;
            axis([0 10 -1.5 1.5]);
        else
            ami=ami*-1;
            if h(n+1)==0
                if ami==1
                    y=(t<n);
                else
                    y=-(t<n);
                end
            else
                if ami==1
                    y=(t<n)-(t==n);
                else
                    y=-(t<n)+(t==n);
                end
            end
            d=plot(t,y);title('Code AMI NRZ');grid on;
            set(d,'LineWidth',2.5);
            hold on;
            axis([0 10 -1.5 1.5]);
        end
        n=n+1;
        end

    case 6
        hold off;
        h =handles.bits;
        n=1;
        h(11)=1;
        ami=-1;
        while n<=10;
            t=n-1:0.001:n;
        if h(n) == 0
            if h(n+1)==0  
                y=(t>n);
            else
                if ami==1
                    y=-(t==n);
                else
                    y=(t==n);
                end
            end
            d=plot(t,y);title('Code AMI RZ');grid on
            set(d,'LineWidth',2.5);
            hold on;
            axis([0 10 -1.5 1.5]);
        else
            ami=ami*-1;
            if h(n+1)==0
                if ami==1
                    y=(t<n-0.5);
                else
                    y=-(t<n-0.5);
                end
            else
                if ami==1
                    y=(t<n-0.5)-(t==n);
                else
                    y=-(t<n-0.5)+(t==n);
                end
            end
            d=plot(t,y);title('Code AMI RZ');grid on;
            set(d,'LineWidth',2.5);
            hold on;
            axis([0 10 -1.5 1.5]);
        end
        n=n+1;
        end

    case 7
        hold off;
        h =handles.bits;
        h=~h;
        n=1;
        h(11)=1;
        while n<=10;
            t=n-1:0.001:n;
        if h(n) == 0
            if h(n+1)==0  
                y=-(t<n)+2*(t<n-0.5)+1*(t==n);
            else
                y=-(t<n)+2*(t<n-0.5)-1*(t==n);
            end
            d=plot(t,y);title('Code MANCHESTER NRZ');grid on
            set(d,'LineWidth',2.5);
            hold on;
            axis([0 10 -1.5 1.5]);
        else
            if h(n+1)==0
                y=(t<n)-2*(t<n-0.5)+1*(t==n);
            else
                y=(t<n)-2*(t<n-0.5)-1*(t==n);
            end
            d=plot(t,y);title('Code MANCHESTER RZ');grid on;
            set(d,'LineWidth',2.5);
            hold on;
            axis([0 10 -1.5 1.5]);
        end
        n=n+1;
        end

end
guidata(hObject, handles);

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

% Hint: popupmenu 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 espectro.
function espectro_Callback(hObject, eventdata, handles)
% hObject    handle to espectro (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close line_code;
espec_lc

⌨️ 快捷键说明

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