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

📄 kuandai.asv

📁 通信系统的GUI设计
💻 ASV
字号:
function varargout = kuandai(varargin)
% KUANDAI M-file for kuandai.fig
%      KUANDAI, by itself, creates a new KUANDAI or raises the existing
%      singleton*.
%
%      H = KUANDAI returns the handle to a new KUANDAI or the handle to
%      the existing singleton*.
%
%      KUANDAI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in KUANDAI.M with the given input arguments.
%
%      KUANDAI('Property','Value',...) creates a new KUANDAI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before kuandai_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to kuandai_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

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help kuandai

% Last Modified by GUIDE v2.5 09-Jan-2009 16:03:25

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @kuandai_OpeningFcn, ...
                   'gui_OutputFcn',  @kuandai_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 kuandai is made visible.
function kuandai_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 kuandai (see VARARGIN)

% Choose default command line output for kuandai
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes kuandai wait for user response (see UIRESUME)
% uiwait(handles.figure1);


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


axes(handles.axes1);
colordef black;
axis off

axes(handles.axes2);
colordef black;
axis off



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


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



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


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



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


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% 产生信号

ts=str2double(get(handles.edit1,'String'));
npow=str2double(get(handles.edit2,'String'));
snr=str2double(get(handles.edit3,'String'));
    
N=2^npow;
N1=1024;
t=ts*(1:N);
ssf=(-N1/2:N1/2-1)/(ts*N1);
x=sqrt(snr)*randn(1,N1);
fftx=fft(x);

axes(handles.axes1);
colordef black;
plot(x,'b');
axis([0,1024,-10,10]);
axis off

axes(handles.axes2);
colordef black;
x=randn(1,N1);
fftx=fft(x);
plot(abs(fftx),'b');
axis([0,1000,0,90]);
axis off


% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% 开始干扰,此时将干扰时间区间值返回,并将信号存储至mat文件中
ts=str2double(get(handles.edit1,'String'));
npow=str2double(get(handles.edit2,'String'));
snr=str2double(get(handles.edit3,'String'));    
N=2^npow;
N1=1024;
t=ts*(1:N);
ssf=(-N1/2:N1/2-1)/(ts*N1);
x1=sqrt(snr)*randn(1,N1);
x2=randn(1,N1);
fftx=fft(x2);

axes(handles.axes1);
colordef black;
plot(x1,'b');
axis([0,1024,-10,10]);
axis off

axes(handles.axes2);
colordef black;
plot(abs(fftx),'b');
axis([0,1000,0,200]);
axis off

% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% 干扰停止,信号和频谱归零处理
axes(handles.axes1);
colordef black;
x=zeros(1,1024);
plot(x,'b');
axis([0,1024,-10,10]);
axis off

axes(handles.axes2);
colordef black;
fftx=zeros(1,1024);
plot(abs(fftx),'b');
axis([0,1000,0,90]);
axis off

% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% 信号动态回放,此时其他操作禁止

set(handles.pushbutton9,'Enable','off');
set(handles.pushbutton10,'Enable','off');
set(handles.pushbutton11,'Enable','off');
set(handles.pushbutton13,'Enable','off');

ts=str2double(get(handles.edit1,'String'));
npow=str2double(get(handles.edit2,'String'));
snr=str2double(get(handles.edit3,'String'));

N1=1024;
t=ts*(1:N1);
ssf=(-N1/2:N1/2-1)/(ts*N1);
x=randn(1,N1);
fftx=fft(x);
axes(handles.axes2);
colordef black;
plot(abs(fftx),'b');
axis([0,1000,0,90]);
axis off

    
for i=1:50
N1=1024;
t=ts*(1:N1);
ssf=(-N1/2:N1/2-1)/(ts*N1);
x=sqrt(snr)*randn(1,N1);
fftx=fft(x);

axes(handles.axes1);
colordef black;
plot(x,'b');
axis([0,1024,-10,10]);
axis off


m(i)=getframe;
end

movie(m);

set(handles.pushbutton9,'Enable','on');
set(handles.pushbutton10,'Enable','on');
set(handles.pushbutton11,'Enable','on');
set(handles.pushbutton13,'Enable','on');
% --- Executes on button press in pushbutton13.
function pushbutton13_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton13 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% 窗口关闭并返回上一层
close(gcf);

⌨️ 快捷键说明

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