实现多普勒信号的处理。 包括信号平滑等操作

源代码在线查看: main.asv

软件大小: 846 K
上传用户: dongchenxi2
关键词: 信号 多普勒 操作
下载地址: 免注册下载 普通下载 VIP

相关代码

				function varargout = main(varargin)
				% MAIN M-file for main.fig
				%      MAIN, by itself, creates a new MAIN or raises the existing
				%      singleton*.
				%
				%      H = MAIN returns the handle to a new MAIN or the handle to
				%      the existing singleton*.
				%
				%      MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
				%      function named CALLBACK in MAIN.M with the given input arguments.
				%
				%      MAIN('Property','Value',...) creates a new MAIN or raises the
				%      existing singleton*.  Starting from the left, property value pairs are
				%      applied to the GUI before main_OpeningFunction gets called.  An
				%      unrecognized property name or invalid value makes property application
				%      stop.  All inputs are passed to main_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 main
				
				% Last Modified by GUIDE v2.5 17-Jun-2008 23:47:33
				
				% Begin initialization code - DO NOT EDIT
				gui_Singleton = 1;
				gui_State = struct('gui_Name',       mfilename, ...
				                   'gui_Singleton',  gui_Singleton, ...
				                   'gui_OpeningFcn', @main_OpeningFcn, ...
				                   'gui_OutputFcn',  @main_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 main is made visible.
				function main_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 main (see VARARGIN)
				
				% Choose default command line output for main
				handles.output = hObject;
				
				% Update handles structure
				guidata(hObject, handles);
				
				% UIWAIT makes main wait for user response (see UIRESUME)
				% uiwait(handles.figure1);
				
				
				% --- Outputs from this function are returned to the command line.
				function varargout = main_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 button press in pushbutton1.
				function pushbutton1_Callback(hObject, eventdata, handles)
				% 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)
				name='*.txt';
				[Filename,path]=uigetfile(name,'打开标准数据文件');        
				filename=[path,Filename];                                       
				[fid,message]=fopen(filename,'rt');
				[data1,count_data1]=fscanf(fid,'%f',inf);
				status=fclose(fid);
				x=1:count_data1;
				plot(x,data1,'r')
				set(gca,'Color',[0,0,0],'XColor',[0,1/2,0],'YColor',[0,1/2,0]);
				grid on;zoom off;zoom xon;
				hold on;
				
				% save data to .mat file
				save dataprocess.mat data1 count_data1;
				
				handles.data1 = data1;
				handles.count_data1 = count_data1;
				guidata(hObject, handles);
				
				% --- Executes on button press in pushbutton4.
				function pushbutton4_Callback(hObject, eventdata, handles)
				% hObject    handle to pushbutton4 (see GCBO)
				% eventdata  reserved - to be defined in a future version of MATLAB
				% handles    structure with handles and user data (see GUIDATA)
				
				data1 = handles.data1;
				count_data1 = handles.count_data1;
				
				freq = 1024; %采样频率
				Y1 = fft(data1, count_data1); %快速傅里叶变换
				f1 = (0:count_data1-1)*freq/count_data1; %频域的点数
				
				figure('Name','Data1 FFT Window','NumberTitle','off');
				subplot(2,1,1);
				plot(f1,abs(Y1)); %频谱图
				xlabel('freqency');
				ylabel('幅值');
				title('频谱图')
				subplot(2,1,2);
				plot(f1,angle(Y1)); %相位谱
				xlabel('freqency');
				ylabel('相位');
				title('相位谱')
				
				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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
				    set(hObject,'BackgroundColor','white');
				end
				
				
				
				
				% --- Executes on button press in pushbutton5.
				function pushbutton5_Callback(hObject, eventdata, handles)
				% hObject    handle to pushbutton5 (see GCBO)
				% eventdata  reserved - to be defined in a future version of MATLAB
				% handles    structure with handles and user data (see GUIDATA)
				sensor = handles.data1;
				len=size(sensor);
				len=len(1,1);
				%数据的五点三次平滑处理
				for a=1:40
				sensor(1) = (69 * sensor(1) + 4 * sensor(2) - 6 * sensor(3) + 4 * sensor(4) - 5 * sensor(5)) / 70;
				sensor(2) = (2 * sensor(1) + 27 * sensor(2) + 12 * sensor(3) - 8 * sensor(4) + 2 * sensor(5)) / 35;
				
				for i = 3 :(len-2)
				      sensor(i) = (-3 * sensor(i - 2) + 12 * sensor(i - 1) + 17 * sensor(i) + 12 * sensor (i + 1) - 3 * sensor(i + 2)) / 35;
				end
				sensor(len - 1) = (2 * sensor (len - 4) - 8 * sensor (len - 3) + 12 * sensor (len - 2) + 27 * sensor (len - 1) + 2 * sensor (len)) / 35;
				sensor (len) = (-1 * sensor (len - 4)+ 4 * sensor (len - 3) - 6 *sensor (len - 2) + 4 * sensor (len - 1) + 69 * sensor (len )) / 70;
				end
				plot(sensor),grid on;
				xlabel('point');ylabel('Voltage(V)');title('截取有用信号');
				zoom xon;
				handles.data1 = sensor;
				guidata(hObject,handles);
				
				
				
				% --- Executes on button press in pushbutton7.
				function pushbutton7_Callback(hObject, eventdata, handles)
				% hObject    handle to pushbutton7 (see GCBO)
				% eventdata  reserved - to be defined in a future version of MATLAB
				% handles    structure with handles and user data (see GUIDATA)
				sensor = handles.data1;
				len=size(sensor);
				len=len(1,1);
				[x1,y1]=ginput;
				[x2,y2]=ginput;
				x1=round(x1);
				%%%%%%%%%%%%%%%%%%
				%x1=1;
				%%%%%%%%%%%%%%%%%%%
				x2=round(x2);
				len=x2-x1+1;
				sensor1=sensor(x1:x2)*1;
				hold off
				plot(sensor1);
				grid on;
				xlabel('point');ylabel('Voltage(V)');title('截取基线');
				
				%Detrend
				[x1,y1]=ginput;
				[x2,y2]=ginput;
				x1=round(x1);
				x2=round(x2);
				ave=mean(sensor1(x1:x2));
				sensor_Partly=sensor1-ave;
				%补零
				temp=zeros(50,1);
				sensor_Partly=[sensor_Partly;temp];
				len=size(sensor_Partly);
				len=len(1,1);
				
				handles.data1 = sensor_Partly;
				guidata(hObject,handles);
				
				
				% --- Executes on button press in pushbutton8.
				function pushbutton8_Callback(hObject, eventdata, handles)
				% hObject    handle to pushbutton8 (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 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)
				
				sensor_Partly = handles.data1;
				len=size(sensor_Partly);
				len=len(1,1);
				%Spectrum before filtered
				fre=abs(fft(sensor_Partly,len));
				fre=fre/fre(1,1);
				f=100000/len*(1:len); %Variable
				plot(f,fre);
				hold off;
				grid on;
				xlabel('Frequency(KHz)');
				ylabel('Amplitude');
				pause;
				plot(f(1:round(len/300)),fre(1:round(len/300))); %Variable
				grid on;
				xlabel('Frequency(KHz)');ylabel('Amplitude');
				pause;
				title('选择滤波截止频率');
				
				
				
				% --- 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)
				%Sampling
				sensor_Partly=sensor_Partly(1:100:len); %Variable
				%Filter design
				[xp,yp]=ginput;
				Fstop=xp(1,1);
				fm=500; %Variable
				fe=Fstop/fm;
				f=[0 fe fe 1];
				m=[1 1 0 0];
				b=fir2(101,f,m); %Variable
				sensor_Partly=filtfilt(b,1,sensor_Partly);
				%The filter frequency response
				[h,w]=freqz(b,1,128);
				plot(f*fm,m,w/pi*fm,abs(h));
				grid on;
				xlabel('Frequency(KHz)');ylabel('Amplitude');title('Frequency Response of The Filter');
				
							

相关资源