From: yomguy Date: Fri, 21 Nov 2008 10:32:42 +0000 (+0000) Subject: Change analysis input and output, plot_impedance, modify template X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f4ab56e3b142a9343ed6184507b11fb2993debe9;p=cnaq.git Change analysis input and output, plot_impedance, modify template git-svn-id: http://svn.parisson.org/svn/CNAQ/trunk@199 5fc3e0e6-29bc-4d03-b52b-c088cb822bde --- diff --git a/CNAQ.fig b/CNAQ.fig index ee274f0..a186180 100644 Binary files a/CNAQ.fig and b/CNAQ.fig differ diff --git a/CNAQ.m b/CNAQ.m index abd4b71..599bd74 100644 --- a/CNAQ.m +++ b/CNAQ.m @@ -34,7 +34,7 @@ function varargout = CNAQ(varargin) % Author: Guillaume Pellerin -% Last Modified by GUIDE v2.5 08-Apr-2008 18:19:43 +% Last Modified by GUIDE v2.5 21-Nov-2008 10:49:08 % CNAQ, by itself, creates a new CNAQ or raises the existing % singleton*. @@ -169,13 +169,17 @@ set(handles.sig_type,'String','Sinus|Chirp|White noise|Pink noise'); set(handles.channels_in,'String','1|1 2|1 2 3|1 2 3 4|1 2 3 4 5 6 7 8'); set(handles.channels_out,'String','1|1 2|1 2 3|1 2 3 4|1 2 3 4 5 6 7 8'); -set(handles.analysis_type,'String','Default'); +set(handles.analysis_type,'String','Transfer function|Impedance'); set(handles.analysis_method,'String','Division|Deconvolution'); set(handles.analysis_domain,'String','Frequency|Time|Time/Frequency'); set(handles.in_on_off,'UserData',device); set(handles.save_button,'UserData',latency); - +set(handles.analysis_input_sig,'String','Generated|Measured'); +set(handles.analysis_output_sig,'String','Measured|Generated'); +set(handles.analysis_input_ch,'String','1|2|3|4|5|6|7|8'); +set(handles.analysis_output_ch,'String','1|2|3|4|5|6|7|8'); + %============================================ % DATA %============================================ @@ -473,3 +477,119 @@ if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgr end +function r_c_Callback(hObject, eventdata, handles) +% hObject handle to r_c (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 r_c as text +% str2double(get(hObject,'String')) returns contents of r_c as a double + + +% --- Executes during object creation, after setting all properties. +function r_c_CreateFcn(hObject, eventdata, handles) +% hObject handle to r_c (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 selection change in analysis_output_sig. +function analysis_output_sig_Callback(hObject, eventdata, handles) +% hObject handle to analysis_output_sig (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 analysis_output_sig contents as cell array +% contents{get(hObject,'Value')} returns selected item from analysis_output_sig + + +% --- Executes during object creation, after setting all properties. +function analysis_output_sig_CreateFcn(hObject, eventdata, handles) +% hObject handle to analysis_output_sig (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 selection change in analysis_output_ch. +function analysis_output_ch_Callback(hObject, eventdata, handles) +% hObject handle to analysis_output_ch (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 analysis_output_ch contents as cell array +% contents{get(hObject,'Value')} returns selected item from analysis_output_ch + + +% --- Executes during object creation, after setting all properties. +function analysis_output_ch_CreateFcn(hObject, eventdata, handles) +% hObject handle to analysis_output_ch (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 selection change in analysis_input_sig. +function analysis_input_sig_Callback(hObject, eventdata, handles) +% hObject handle to analysis_input_sig (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 analysis_input_sig contents as cell array +% contents{get(hObject,'Value')} returns selected item from analysis_input_sig + + +% --- Executes during object creation, after setting all properties. +function analysis_input_sig_CreateFcn(hObject, eventdata, handles) +% hObject handle to analysis_input_sig (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 selection change in analysis_input_ch. +function analysis_input_ch_Callback(hObject, eventdata, handles) +% hObject handle to analysis_input_ch (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 analysis_input_ch contents as cell array +% contents{get(hObject,'Value')} returns selected item from analysis_input_ch + + +% --- Executes during object creation, after setting all properties. +function analysis_input_ch_CreateFcn(hObject, eventdata, handles) +% hObject handle to analysis_input_ch (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 + + diff --git a/tools/plot_impedance.m b/tools/plot_impedance.m index 93ccbe6..af1f013 100644 --- a/tools/plot_impedance.m +++ b/tools/plot_impedance.m @@ -1,7 +1,7 @@ % Loudspeaker impedance post-processing from a 2 voice acquisition from CNAQ % Copyright (C) Guillaume Pellerin -function plot_impedance(fic_mes, R_c, option) +function plot_impedance(sig_mes, R_c, option) % fic_resistance : the (CNAQ) MAT file containing the transfert function of the % resistance @@ -11,7 +11,7 @@ function plot_impedance(fic_mes, R_c, option) % option : 'lin' or 'log' to plot the frequency with a linear or % logarithmic scale respectively -load(fic_mes); +%load(fic_mes); U_r = sig_mes(:,1); I_r = sig_mes(:,1)/R_c; U_hp = sig_mes(:,2)-U_r; @@ -33,7 +33,7 @@ f_min_ind = f_min_list(length(f_min_list)); figure subplot(2,1,1); -data = abs(fz); +data = smooth(abs(fz),20); if option == 'lin' plot(f,data) elseif option == 'log' @@ -46,7 +46,7 @@ title(['Module de l impedance']); grid on subplot(2,1,2); -data = unwrap(angle(fz)); +data = smooth(unwrap(angle(fz)),20); if option == 'lin' plot(f,data) elseif option == 'log' diff --git a/tools/plot_main.m b/tools/plot_main.m index 5350094..34803c8 100644 --- a/tools/plot_main.m +++ b/tools/plot_main.m @@ -21,25 +21,50 @@ function plot_main(handles) type = get(handles.analysis_type,'Value'); method = get(handles.analysis_method,'Value'); domain = get(handles.analysis_domain,'Value'); - - % Compute excitation spectrum - [rep_imp_exc, spec_exc] = get_ri_spec(f, sig_exc, sig_exc, f_s, method); - len_spec_exc = length(spec_exc); - spec_exc = spec_exc(1:len_spec_exc/2); + analysis_input_sig = get(handles.analysis_input_sig,'Value'); + analysis_output_sig = get(handles.analysis_output_sig,'Value'); + analysis_input_ch = get(handles.analysis_input_ch,'Value'); + analysis_output_ch = get(handles.analysis_output_ch,'Value'); + r_c = get(handles.r_c,'Value'); + + if analysis_input_sig == 1 + input_sig = sig_exc; + elseif analysis_input_sig == 2 + input_sig = sig_mes; + end + if analysis_output_sig == 2 + output_sig = sig_exc; + elseif analysis_output_sig == 1 + output_sig = sig_mes; + end + + if type == 1 + % Transfer function - % Compute all Ris and specs - for i=1:n_col_sig_mes - channel = num2str(i); - [rep_imp_mes, spec_mes] = get_ri_spec(f, sig_exc, sig_mes(:,i), f_s, method); - len_spec_mes = length(spec_mes); - spec_mes = spec_mes(1:len_spec_mes/2); - % Plot results - f_lin = [0:f_s/len_spec_mes:f_s/2]; - f_lin = f_lin(1:length(f_lin)-1); - plot_mes(t, f_lin, f_s, f_min, f_max, sig_exc, sig_mes(:,i), rep_imp_mes, spec_mes, spec_exc, id, channel, username, comment, i, domain); + % Compute excitation spectrum + [rep_imp_exc, spec_exc] = get_ri_spec(f, sig_exc, sig_exc, f_s, method); + len_spec_exc = length(spec_exc); + spec_exc = spec_exc(1:len_spec_exc/2); + + % Compute all Ris and specs + for i=1:n_col_sig_mes + channel = num2str(i); + [rep_imp_mes, spec_mes] = get_ri_spec(f, input_sig, output_sig(:,i), f_s, method); + len_spec_mes = length(spec_mes); + spec_mes = spec_mes(1:len_spec_mes/2); + % Plot results + f_lin = [0:f_s/len_spec_mes:f_s/2]; + f_lin = f_lin(1:length(f_lin)-1); + plot_mes(t, f_lin, f_s, f_min, f_max, input_sig, output_sig(:,i), rep_imp_mes, spec_mes, spec_exc, id, channel, username, comment, i, domain); + end end - set(handles.close_button,'UserData',f_lin'); + if type == 2 + % Impedance + plot_impedance(sig_mes, r_c) + end + + set(handles.close_button,'UserData','f_lin'); set(handles.plot,'UserData',t); end