]> git.parisson.com Git - cnaq.git/commitdiff
Change analysis input and output, plot_impedance, modify template
authoryomguy <yomguy@5fc3e0e6-29bc-4d03-b52b-c088cb822bde>
Fri, 21 Nov 2008 10:32:42 +0000 (10:32 +0000)
committeryomguy <yomguy@5fc3e0e6-29bc-4d03-b52b-c088cb822bde>
Fri, 21 Nov 2008 10:32:42 +0000 (10:32 +0000)
git-svn-id: http://svn.parisson.org/svn/CNAQ/trunk@199 5fc3e0e6-29bc-4d03-b52b-c088cb822bde

CNAQ.fig
CNAQ.m
tools/plot_impedance.m
tools/plot_main.m

index ee274f0e603cf65c50e04c892e75ddad1aa57f31..a186180f7387924c02973692357eba1fc788275a 100644 (file)
Binary files a/CNAQ.fig and b/CNAQ.fig differ
diff --git a/CNAQ.m b/CNAQ.m
index abd4b7114a8314e2f4d1625eb2ed81d23342ab75..599bd746cfbab023f1b390d7503a9d9b93bb8077 100644 (file)
--- a/CNAQ.m
+++ b/CNAQ.m
@@ -34,7 +34,7 @@ function varargout = CNAQ(varargin)
 \r
 %  Author: Guillaume Pellerin <guillaume.pellerin@cnam.fr>\r
 \r
-% Last Modified by GUIDE v2.5 08-Apr-2008 18:19:43\r
+% Last Modified by GUIDE v2.5 21-Nov-2008 10:49:08\r
 \r
 %      CNAQ, by itself, creates a new CNAQ or raises the existing\r
 %      singleton*.\r
@@ -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');\r
 set(handles.channels_out,'String','1|1 2|1 2 3|1 2 3 4|1 2 3 4 5 6 7 8');\r
 \r
-set(handles.analysis_type,'String','Default');\r
+set(handles.analysis_type,'String','Transfer function|Impedance');\r
 set(handles.analysis_method,'String','Division|Deconvolution');\r
 set(handles.analysis_domain,'String','Frequency|Time|Time/Frequency');\r
 set(handles.in_on_off,'UserData',device);\r
 set(handles.save_button,'UserData',latency);\r
 \r
-    \r
+set(handles.analysis_input_sig,'String','Generated|Measured');\r
+set(handles.analysis_output_sig,'String','Measured|Generated');\r
+set(handles.analysis_input_ch,'String','1|2|3|4|5|6|7|8');\r
+set(handles.analysis_output_ch,'String','1|2|3|4|5|6|7|8');\r
+\r
 %============================================\r
 % DATA\r
 %============================================\r
@@ -473,3 +477,119 @@ if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgr
 end\r
 \r
 \r
+function r_c_Callback(hObject, eventdata, handles)\r
+% hObject    handle to r_c (see GCBO)\r
+% eventdata  reserved - to be defined in a future version of MATLAB\r
+% handles    structure with handles and user data (see GUIDATA)\r
+\r
+% Hints: get(hObject,'String') returns contents of r_c as text\r
+%        str2double(get(hObject,'String')) returns contents of r_c as a double\r
+\r
+\r
+% --- Executes during object creation, after setting all properties.\r
+function r_c_CreateFcn(hObject, eventdata, handles)\r
+% hObject    handle to r_c (see GCBO)\r
+% eventdata  reserved - to be defined in a future version of MATLAB\r
+% handles    empty - handles not created until after all CreateFcns called\r
+\r
+% Hint: edit controls usually have a white background on Windows.\r
+%       See ISPC and COMPUTER.\r
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))\r
+    set(hObject,'BackgroundColor','white');\r
+end\r
+\r
+\r
+\r
+\r
+% --- Executes on selection change in analysis_output_sig.\r
+function analysis_output_sig_Callback(hObject, eventdata, handles)\r
+% hObject    handle to analysis_output_sig (see GCBO)\r
+% eventdata  reserved - to be defined in a future version of MATLAB\r
+% handles    structure with handles and user data (see GUIDATA)\r
+\r
+% Hints: contents = get(hObject,'String') returns analysis_output_sig contents as cell array\r
+%        contents{get(hObject,'Value')} returns selected item from analysis_output_sig\r
+\r
+\r
+% --- Executes during object creation, after setting all properties.\r
+function analysis_output_sig_CreateFcn(hObject, eventdata, handles)\r
+% hObject    handle to analysis_output_sig (see GCBO)\r
+% eventdata  reserved - to be defined in a future version of MATLAB\r
+% handles    empty - handles not created until after all CreateFcns called\r
+\r
+% Hint: popupmenu controls usually have a white background on Windows.\r
+%       See ISPC and COMPUTER.\r
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))\r
+    set(hObject,'BackgroundColor','white');\r
+end\r
+\r
+\r
+% --- Executes on selection change in analysis_output_ch.\r
+function analysis_output_ch_Callback(hObject, eventdata, handles)\r
+% hObject    handle to analysis_output_ch (see GCBO)\r
+% eventdata  reserved - to be defined in a future version of MATLAB\r
+% handles    structure with handles and user data (see GUIDATA)\r
+\r
+% Hints: contents = get(hObject,'String') returns analysis_output_ch contents as cell array\r
+%        contents{get(hObject,'Value')} returns selected item from analysis_output_ch\r
+\r
+\r
+% --- Executes during object creation, after setting all properties.\r
+function analysis_output_ch_CreateFcn(hObject, eventdata, handles)\r
+% hObject    handle to analysis_output_ch (see GCBO)\r
+% eventdata  reserved - to be defined in a future version of MATLAB\r
+% handles    empty - handles not created until after all CreateFcns called\r
+\r
+% Hint: popupmenu controls usually have a white background on Windows.\r
+%       See ISPC and COMPUTER.\r
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))\r
+    set(hObject,'BackgroundColor','white');\r
+end\r
+\r
+\r
+% --- Executes on selection change in analysis_input_sig.\r
+function analysis_input_sig_Callback(hObject, eventdata, handles)\r
+% hObject    handle to analysis_input_sig (see GCBO)\r
+% eventdata  reserved - to be defined in a future version of MATLAB\r
+% handles    structure with handles and user data (see GUIDATA)\r
+\r
+% Hints: contents = get(hObject,'String') returns analysis_input_sig contents as cell array\r
+%        contents{get(hObject,'Value')} returns selected item from analysis_input_sig\r
+\r
+\r
+% --- Executes during object creation, after setting all properties.\r
+function analysis_input_sig_CreateFcn(hObject, eventdata, handles)\r
+% hObject    handle to analysis_input_sig (see GCBO)\r
+% eventdata  reserved - to be defined in a future version of MATLAB\r
+% handles    empty - handles not created until after all CreateFcns called\r
+\r
+% Hint: popupmenu controls usually have a white background on Windows.\r
+%       See ISPC and COMPUTER.\r
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))\r
+    set(hObject,'BackgroundColor','white');\r
+end\r
+\r
+\r
+% --- Executes on selection change in analysis_input_ch.\r
+function analysis_input_ch_Callback(hObject, eventdata, handles)\r
+% hObject    handle to analysis_input_ch (see GCBO)\r
+% eventdata  reserved - to be defined in a future version of MATLAB\r
+% handles    structure with handles and user data (see GUIDATA)\r
+\r
+% Hints: contents = get(hObject,'String') returns analysis_input_ch contents as cell array\r
+%        contents{get(hObject,'Value')} returns selected item from analysis_input_ch\r
+\r
+\r
+% --- Executes during object creation, after setting all properties.\r
+function analysis_input_ch_CreateFcn(hObject, eventdata, handles)\r
+% hObject    handle to analysis_input_ch (see GCBO)\r
+% eventdata  reserved - to be defined in a future version of MATLAB\r
+% handles    empty - handles not created until after all CreateFcns called\r
+\r
+% Hint: popupmenu controls usually have a white background on Windows.\r
+%       See ISPC and COMPUTER.\r
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))\r
+    set(hObject,'BackgroundColor','white');\r
+end\r
+\r
+\r
index 93ccbe6eb88373957849ae37d2ed48951423ee61..af1f0138b534d92de016350dafc1f7f3f5ed69c1 100644 (file)
@@ -1,7 +1,7 @@
 % Loudspeaker impedance post-processing from a 2 voice acquisition from CNAQ\r
 % Copyright (C) Guillaume Pellerin\r
 \r
-function plot_impedance(fic_mes, R_c, option)\r
+function plot_impedance(sig_mes, R_c, option)\r
 \r
 % fic_resistance : the (CNAQ) MAT file containing the transfert function of the\r
 % resistance\r
@@ -11,7 +11,7 @@ function plot_impedance(fic_mes, R_c, option)
 % option : 'lin' or 'log' to plot the frequency with a linear or\r
 % logarithmic scale respectively\r
 \r
-load(fic_mes);\r
+%load(fic_mes);\r
 U_r = sig_mes(:,1);\r
 I_r = sig_mes(:,1)/R_c;\r
 U_hp = sig_mes(:,2)-U_r;\r
@@ -33,7 +33,7 @@ f_min_ind = f_min_list(length(f_min_list));
 \r
 figure\r
 subplot(2,1,1);\r
-data = abs(fz);\r
+data = smooth(abs(fz),20);\r
 if option == 'lin'\r
     plot(f,data)\r
 elseif option == 'log'\r
@@ -46,7 +46,7 @@ title(['Module de l impedance']);
 grid on\r
 \r
 subplot(2,1,2);\r
-data = unwrap(angle(fz));\r
+data = smooth(unwrap(angle(fz)),20);\r
 if option == 'lin'\r
     plot(f,data)\r
 elseif option == 'log'\r
index 5350094e8d0068ce85313c3006e155773b8a33cb..34803c8f4c9ef5497871d110b8313dc8ad199c6f 100644 (file)
@@ -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