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

📄 plusmoderatsignal.m

📁 matlab的初学者可以借鉴的程序
💻 M
字号:
function varargout = plusmoderatsignal(varargin)
% PLUSMODERATSIGNAL M-file for plusmoderatsignal.fig
%      PLUSMODERATSIGNAL, by itself, creates a new PLUSMODERATSIGNAL or raises the existing
%      singleton*.
%
%      H = PLUSMODERATSIGNAL returns the handle to a new PLUSMODERATSIGNAL or the handle to
%      the existing singleton*.
%
%      PLUSMODERATSIGNAL('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in PLUSMODERATSIGNAL.M with the given input arguments.
%
%      PLUSMODERATSIGNAL('Property','Value',...) creates a new PLUSMODERATSIGNAL or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before plusmoderatsignal_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to plusmoderatsignal_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

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

% Last Modified by GUIDE v2.5 10-May-2008 08:02:55

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

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

% Update handles structure
guidata(hObject, handles);

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


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


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (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 popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1


% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (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



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


% --- Executes during object creation, after setting all properties.
function FZ_CreateFcn(hObject, eventdata, handles)
% hObject    handle to FZ (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



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


% --- Executes during object creation, after setting all properties.
function a_CreateFcn(hObject, eventdata, handles)
% hObject    handle to a (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



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


% --- Executes during object creation, after setting all properties.
function fs_CreateFcn(hObject, eventdata, handles)
% hObject    handle to fs (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



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


% --- Executes during object creation, after setting all properties.
function fft_num_CreateFcn(hObject, eventdata, handles)
% hObject    handle to fft_num (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 button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
a = str2double(get(handles.a,'String'));
noise_a=str2double(get(handles.noise_a,'String'));%噪声幅度
fz = 1e+6*str2double(get(handles.FZ,'String'));
prf = 1e+3*str2double(get(handles.prf,'String'));%重负频率
zkb = str2double(get(handles.zkb,'String'));%占空比
fs = 1e+6*str2double(get(handles.fs,'String'));%采样频率
N = str2double(get(handles.fft_num,'String'));%点数
val1 = get(handles.popupmenu1,'Value');%得到选项控件中的値,按从1----2的顺序排列
n=0:1/fs:1/prf-1/fs;
t=N/fs;%总长度
% tn=0:1/fs:N/fs;
% t1=length(tn);
m=ceil(t*prf);%有可能不是整数倍,所以用ceil向大于零的方向取整
spt=(square(2*pi*prf*n,zkb)+1)/2;
st=a*cos(2*pi*fz*n);

switch val1
case 1%简单脉冲调制
    y1=st.*spt; 
%    y2=length(y1);
    y=repmat(y1,1,m);
case 2%加噪声
    y1=st.*spt+noise_a*randn(1,length(n)); 
     y=repmat(y1,1,m);
end
axes(handles.axes1) % Select the proper axes

plot(y);
set(handles.axes2,'XMinorTick','on')
title('时域波形');
grid on
%%%%%%%%%%%%频域显示%%%%%%%%%%
Y_FFT=fftshift(fft(y,N));
 pyy=Y_FFT.*conj(Y_FFT)/length(Y_FFT);
% pyy=abs(Y_FFT);
axes(handles.axes2)

f=(length(Y_FFT)/2:length(Y_FFT))*fs/length(Y_FFT);
plot(f-fs/2,pyy(length(Y_FFT)/2:length(Y_FFT)))
title('频域波形')
xlabel('频率(hz)');
ylabel('幅度')
set(handles.axes2,'XMinorTick','on')
grid on


% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
close;
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (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 popupmenu2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu2


% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (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



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


% --- Executes during object creation, after setting all properties.
function zkb_CreateFcn(hObject, eventdata, handles)
% hObject    handle to zkb (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



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


% --- Executes during object creation, after setting all properties.
function prf_CreateFcn(hObject, eventdata, handles)
% hObject    handle to prf (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





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


% --- Executes during object creation, after setting all properties.
function noise_a_CreateFcn(hObject, eventdata, handles)
% hObject    handle to noise_a (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


⌨️ 快捷键说明

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