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

📄 cr1dmod.m

📁 matlab中常用电法各种装置的电磁正演计算
💻 M
📖 第 1 页 / 共 4 页
字号:
guidata(hObject, handles);


% *****************************************************************
% * Callback functions related to model input section             *
% *****************************************************************

% --------------------------------------------------------------------
% --- Executes on selection change in Layer_popup.function Layer_popup_Callback(hObject, eventdata, handles)
update_layer_param(handles);
% --------------------------------------------------------------------function h_edit_Callback(hObject, eventdata, handles)
layer_index = get(handles.Layer_popup,'Value');
handles.layers(layer_index).thickness = str2num(get(hObject,'String'));

if handles.layers(layer_index).thickness > 0
    
    handles = update_model(handles);
    
    ylimmits = ylim;
    set(handles.axes1,'ylim',([-1 2/5] * (9/7 *                         ...
        handles.layers(end).depth_to_top)));
        
    if strcmp(handles.config.type,'TEM Central Loop')
        yscale = diff(get(handles.axes1,'ylim'));
        t = sin([0:pi/100:pi]).*yscale./70;
        set(handles.config.plot_handle(1),'ydata',t.*4);
        set(handles.config.plot_handle(2),'ydata',t.*1);
    end
    guidata(hObject, handles);
else
    delete_button_Callback(hObject, [], handles);
end % if

handles = guidata(hObject);
handles = update_model(handles);
guidata(hObject, handles);
% --------------------------------------------------------------------function DC_res_edit_Callback(hObject, eventdata, handles)
layer_index = get(handles.Layer_popup,'Value');
handles.layers(layer_index).rho = str2num(get(hObject,'String'));

handles = update_model(handles);

guidata(hObject, handles);
% --------------------------------------------------------------------function m_edit_Callback(hObject, eventdata, handles)
layer_index = get(handles.Layer_popup,'Value');
handles.layers(layer_index).m = str2num(get(hObject,'String'));

handles = update_model(handles);

guidata(hObject, handles);
% --------------------------------------------------------------------function Tau_edit_Callback(hObject, eventdata, handles)
layer_index = get(handles.Layer_popup,'Value');
handles.layers(layer_index).tau = str2num(get(hObject,'String'));

handles = update_model(handles);

guidata(hObject, handles);
% --------------------------------------------------------------------function c_edit_Callback(hObject, eventdata, handles)
layer_index = get(handles.Layer_popup,'Value');
handles.layers(layer_index).c = str2num(get(hObject,'String'));

handles = update_model(handles);

guidata(hObject, handles);
% --------------------------------------------------------------------function Eps_r_edit_Callback(hObject, eventdata, handles)
layer_index = get(handles.Layer_popup,'Value');
handles.layers(layer_index).eps_r = str2num(get(hObject,'String'));

handles = update_model(handles);

guidata(hObject, handles);
% --------------------------------------------------------------------function Mu_edit_Callback(hObject, eventdata, handles)layer_index = get(handles.Layer_popup,'Value');

% New code to accomodate test for mu==1;
str = get(hObject,'String');
num = str2num(str);

if ~isempty(num)
    handles.layers(layer_index).mu = str;
end
set(handles.Mu_edit, 'string', handles.layers(layer_index).mu);

guidata(hObject, handles);


% *****************************************************************
% * Callback functions related to model input section             *
% *****************************************************************
% --------------------------------------------------------------------
% --- function to update model plot.
function handles = update_model(handles);

layers = handles.layers;

ylimmits = ylim;
xlimmits = xlim;

set(handles.surface,'xdata',xlimmits);

for k=1:length(layers)-1
    % recalculate depths 
    layers(k+1).depth_to_top = layers(k).depth_to_top +                 ...
        layers(k).thickness;
    
    % Update interface locations
    if isfield(layers(k),'interface_handle') &                          ...
            ishandle(layers(k).interface_handle)
        set(layers(k).interface_handle,'ydata',                         ...
            [-1 -1] * layers(k+1).depth_to_top, 'xdata',xlimmits);
    elseif ~isinf(layers(k).thickness)
        % plot interface
        layers(k).interface_handle = plot(get(handles.axes1,'xlim'),    ...
            [-1 -1].*(layers(k).depth_to_top+layers(k).thickness),'-k');  
        set(layers(k).interface_handle,'ButtonDownFcn',                 ...
            @interface_ButtonDown_Callback);
    end
    
    % Update labels of layers
    % Thickness label 
    if layers(k).m ~= 0 && layers(k).tau ~= 0 && layers(k).c ~= 0
        tmpStr = '^{C-C}';
    else
        tmpStr = '';
    end % if
    
    if isfield(layers(k),'prop_lab_handle') &                           ...
            ishandle(layers(k).prop_lab_handle)
        set(layers(k).prop_lab_handle,'String',                         ...
            ['h = ' sprintf('%.1f m', layers(k).thickness)              ...
                '    \rho_{DC}' tmpStr ' = ' sprintf('%.1f \\Omegam',   ...
                layers(k).rho)],                                        ...
            'Position', [mean(get(handles.axes1,'xlim')),               ...
                -mean([layers(k).depth_to_top                           ...
                    (layers(k).depth_to_top+layers(k).thickness)])],    ...
            'ButtonDownFcn', {@layer_label_Callback, k});    
    else
        layers(k).prop_lab_handle = text(mean(get(handles.axes1,        ...
            'xlim')), -mean([layers(k).depth_to_top                     ...
                (layers(k).depth_to_top+layers(k).thickness)]),         ...
            ['h = ' sprintf('%.1f m', layers(k).thickness)              ...
                '    \rho_{DC}' tmpStr ' = ' sprintf('%.1f \\Omegam',   ...
                layers(k).rho)],                                        ...
            'VerticalAlignment',   'middle',                            ...
            'HorizontalAlignment', 'center',                            ...
            'FontSize',             8,                                  ...
            'ButtonDownFcn',        {@layer_label_Callback, k});    
    end
    
    if isfield(layers(k),'label_handle') & ishandle(layers(k).label_handle)
        set(layers(k).label_handle,'Position',...
            [0.05*(xlimmits(2)-xlimmits(1))+xlimmits(1),                ...
                ylimmits(1)/120-layers(k).depth_to_top],                ...
            'String',['Layer ' num2str(k)],                             ...
            'ButtonDownFcn', {@layer_label_Callback, k});
    else
        layers(k).label_handle = text(0.05*(xlimmits(2)-xlimmits(1))+   ...
            xlimmits(1), ylimmits(1)/120-layers(k).depth_to_top,        ...
            ['Layer ' num2str(k)],                                      ...
            'VerticalAlignment',   'top',                               ...
            'HorizontalAlignment', 'left',                              ...
            'FontSize',             8,                                  ...
            'ButtonDownFcn',        {@layer_label_Callback, k});    
    end
end

if isfield(layers(end),'label_handle') & ishandle(layers(end).label_handle)
    set(layers(end).label_handle,'Position',                            ...
        [0.05*(xlimmits(2)-xlimmits(1))+xlimmits(1),                    ...
            ylimmits(1)/120-layers(end).depth_to_top],                  ...
        'ButtonDownFcn', {@layer_label_Callback, length(layers)});
else
    layers(end).label_handle = text(0.05*(xlimmits(2)-xlimmits(1))+     ...
        xlimmits(1), ylimmits(1)/120-layers(end).depth_to_top,          ...
        'Lower half-space',                                             ...
        'VerticalAlignment',   'top',                                   ...
        'HorizontalAlignment', 'left',                                  ...
        'FontSize',             8,                                      ...
        'ButtonDownFcn',        {@layer_label_Callback, length(layers)});
end


if layers(end).m ~= 0 && layers(end).tau ~= 0 && layers(end).c ~= 0
    tmpStr = '^{C-C}';
else
    tmpStr = '';
end % if
if isfield(layers(end),'prop_lab_handle') &                             ...
        ishandle(layers(end).prop_lab_handle)
    set(layers(end).prop_lab_handle,'String',                           ...
        ['\rho_{DC}' tmpStr ' = ' sprintf('%.1f \\Omegam',              ...
            layers(end).rho)],                                          ...
        'Position', [mean(get(handles.axes1,'xlim')),                   ...
            mean([-layers(end).depth_to_top ylimmits(1)])],             ...
        'ButtonDownFcn', {@layer_label_Callback, length(layers)});
else
    layers(end).prop_lab_handle = text(mean(get(handles.axes1,          ...
        'xlim')), mean([-layers(end).depth_to_top ylimmits(1)]),        ...
        ['\rho_{DC}' tmpStr ' = ' sprintf('%.1f \\Omegam',              ...
            layers(k).rho)],                                            ...
        'VerticalAlignment',   'middle',                                ...
        'HorizontalAlignment', 'center',                                ...
        'FontSize',             8,                                      ...
        'ButtonDownFcn',        {@layer_label_Callback, length(layers)});
end

handles.layers = layers;


% --------------------------------------------------------------------
% --- function to update layer parameters input section.
function update_layer_param(handles);

layer_index = get(handles.Layer_popup,'Value');
contents = get(handles.Layer_popup,'String');

for k = 1:length(handles.layers)-1
    pop_string{k} = ['Layer ' num2str(k)];
end
pop_string{length(handles.layers)} = 'Lower half-space';
    
set(handles.Layer_popup,'String',pop_string); 

if strcmp(pop_string{layer_index},'Lower half-space')
    set(handles.h_edit,'Enable','off');
else
    set(handles.h_edit,'Enable','on');
end

set(handles.h_edit,'String',num2str(handles.layers(layer_index).thickness));
set(handles.DC_res_edit,'String',num2str(handles.layers(layer_index).rho));
set(handles.m_edit,'String',num2str(handles.layers(layer_index).m));
set(handles.Tau_edit,'String',num2str(handles.layers(layer_index).tau));
set(handles.c_edit,'String',num2str(handles.layers(layer_index).c));
set(handles.Mu_edit,'String',handles.layers(layer_index).mu);
%set(handles.Mu_edit,'String',num2str(handles.layers(layer_index).mu));
set(handles.Eps_r_edit,'String',num2str(handles.layers(layer_index).eps_r));

% print label of selected layer in bold
set(handles.layers(layer_index).label_handle,'FontWeight','bold');
set([handles.layers(find([1:length(handles.layers)]~=                   ...
        layer_index)).label_handle],'FontWeight','normal');

% --------------------------------------------------------------------
% --- function to update configuration input section and plot.
function handles = update_config(handles);

switch handles.config.type
    case {'Dipole-Dipole','*Capacitance*'}
        set(handles.topview_button,'enable','on');
        set([handles.Aspac_edit handles.Aspactxt],'visible','on');
        set([handles.Nspac_edit handles.Nspactxt],'visible','on');
        set([handles.OA_edit handles.OA_txt],'visible','off');
        set([handles.OM_edit handles.OM_txt],'visible','off');
        set([handles.Tx_side_edit handles.Tx_side_txt],'visible','off');
        set([handles.Rx_area_edit handles.Rx_area_txt],'visible','off');
        set([handles.Rspac_edit handles.Rspac_txt], 'visible', 'off');
        
        if length(handles.config.Aspac)>1
            tmpstr =  ['[' sprintf('%i ',handles.config.Aspac)];
            tmpstr(end) = ']';
            set(handles.Aspac_edit,'String',tmpstr,'visible','on');
        else
            set(handles.Aspac_edit, 'String',                           ...
                num2str(handles.config.Aspac),'visible','on');
        end
        if length(handles.config.Nspac)>1
            tmpstr =  ['[' sprintf('%i ',handles.config.Nspac)];
            tmpstr(end) = ']';
            set(handles.Nspac_edit,'String',tmpstr,'visible','on');
        else
            set(handles.Nspac_edit, 'String',                           ...
                num2str(handles.config.Nspac),'visible','on');
        end
        
        % transmitter dipole            C1  a  C2     P1  a  P2
        % transmitter dipole            o------o      o------o            
        % receiver dipole                 Tx     n*a    Rx
        
        handles.config.C1 = [-handles.config.Aspac(1)-...
                0.5*handles.config.Aspac(1)*handles.config.Nspac(1) 0 0];  
        handles.config.C2 = [handles.config.C1(1)+...
                handles.config.Aspac(1) 0 0];                              
        handles.config.P1 = [handles.config.C2(1)+...                      
                handles.config.Nspac(1)*handles.config.Aspac(1) 0 0];   
        handles.config.P2 = [handles.config.P1(1)+...                      
                handles.config.Aspac(1) 0 0];     
        handles.config.Cwire = [];
        handles.config.Pwire = [];
    case {'General Surface Array', '*GSA capacitance*'};
        set(handles.topview_button,'enable','on');
        set([handles.Aspac_edit handles.Aspactxt],'visible','off');
        set([handles.Nspac_edit handles.Nspactxt],'visible','off');
        set([handles.OA_edit handles.OA_txt],'visible','off');
        set([handles.OM_edit handles.OM_txt],'visible','off');
        set([handles.Tx_side_edit handles.Tx_side_txt],'visible','off');
        set([handles.Rx_area_edit handles.Rx_area_txt],'visible','off');
        set([handles.Rspac_edit handles.Rspac_txt], 'visible', 'off');
    case {'Wenner'}
        set(handles.topview_button,'enable','on');        
        set([handles.Aspac_edit handles.Aspactxt],'visible','on');
        set([handles.Nspac_edit handles.Nspactxt],'visible','off');
        set([handles.OA_edit handles.OA_txt],'visible','off');
        set([handles.OM_edit handles.OM_txt],'visible','off');
        set([handles.Tx_side_edit handles.Tx_side_txt],'visible','off');
        set([handles.Rx_area_edit handles.Rx_area_txt],'visible','off');
        set([handles.Rspac_edit handles.Rspac_txt], 'visible', 'off');
        
        if length(handles.config.Aspac)>1

⌨️ 快捷键说明

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