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

📄 topview.m

📁 matlab中常用电法各种装置的电磁正演计算
💻 M
📖 第 1 页 / 共 3 页
字号:
function varargout = topview(varargin)

% Usage:
%    config = topview(config);
%
% topview.m is part of the CR1Dmod forward modeling package. The function
% related to the topview.fig GUI, which allows the user to place electrodes
% and wires arbitrarily on the surface of the half-space.
% The user must ensure that no wires cross! There is no automatic 
% detection of this source of error implemented at this time.
%
% 'config' is an optional input structure with at least the fields:
%        type:    Electrode array ('Dipole-Dipole', 'Wenner',
%                                  'Schlumberger' or 'General Surface Array')
%        C1:      [x,y,z] coordinates of first current electrode
%        C2:      [x,y,z] coordinates of second current electrode
%        P1:      [x,y,z] coordinates of first potential electrode
%        P2:      [x,y,z] coordinates of second potential electrode
%
% topview.m returns a new config structure which in addition to the above 
% holds the fields Cwire and Pwire with coordinates of the additional points 
% defining the wires. The new structure also holds the fields Aspac and
% Nspace, which only has a physical significance in dipole-dipole and 
% wenner configrations.
%
% Written by:
% Thomas Ingeman-Nielsen
% The Arctic Technology Center, BYG
% Technical University of Denmark
% Email: tin@byg.dtu.dk

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @topview_OpeningFcn, ...
                   'gui_OutputFcn',  @topview_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(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 topview is made visible.
function topview_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 topview (see VARARGIN)

% Choose default command line output for topview
handles.output = [];

% Update handles structure
guidata(hObject, handles);

set(handles.Add_button, 'enable', 'off');

handles.config.type = 'Dipole-Dipole';
handles.config.Aspac = 100;
handles.config.Nspac = 1;
handles.config.C1 = [-handles.config.Aspac-...
        0.5*handles.config.Aspac*handles.config.Nspac 0 0];  % transmitter dipole            C1  a  C2     P1  a  P2
handles.config.C2 = [handles.config.C1(1)+...
        handles.config.Aspac(1) 0 0];                        % transmitter dipole            o------o      o------o    
handles.config.P1 = [handles.config.C2(1)+...                 % receiver dipole                 Tx     n*a    Rx
        handles.config.Nspac(1)*handles.config.Aspac(1) 0 0];   
handles.config.P2 = [handles.config.P1(1)+...                 % receiver dipole
        handles.config.Aspac(1) 0 0];     
handles.config.Cwire = [];
handles.config.Pwire = [];

handles.topview.Cwire = line([handles.config.C1(1) handles.config.C2(1)],...
    [handles.config.C1(2) handles.config.C2(2)],'MarkerSize',6, ...
    'markeredgecolor','k','markerfacecolor','b','marker','none',...
    'linewidth',2,'color','k','ButtonDownFcn',{@apex_ButtonDownFcn, 'Cwire'});

handles.topview.Pwire = line([handles.config.P1(1) handles.config.P2(1)],...
    [handles.config.P1(2) handles.config.P2(2)],'MarkerSize',6, ...
    'markeredgecolor','k','markerfacecolor','b','marker','none',...
    'linewidth',2,'color','k','ButtonDownFcn',{@apex_ButtonDownFcn, 'Pwire'});

handles.topview.current_apex = {'Cwire', 0, []};

handles.topview.C1 = line(handles.config.C1(1), handles.config.C1(2),'MarkerSize',8, ...
    'markeredgecolor','k','markerfacecolor','r','marker','o',...
    'ButtonDownFcn','topview(''electrode_ButtonDownFcn'',gcbo,[],guidata(gcbo),''C1'');');
handles.topview.C2 = line(handles.config.C2(1), handles.config.C2(2),'MarkerSize',8, ...
    'markeredgecolor','k','markerfacecolor','r','marker','o',...
    'ButtonDownFcn','topview(''electrode_ButtonDownFcn'',gcbo,[],guidata(gcbo),''C2'');');
handles.topview.P1 = line(handles.config.P1(1), handles.config.P1(2),'MarkerSize',8, ...
    'markeredgecolor','k','markerfacecolor','b','marker','o',...
    'ButtonDownFcn','topview(''electrode_ButtonDownFcn'',gcbo,[],guidata(gcbo),''P1'');');
handles.topview.P2 = line(handles.config.P2(1), handles.config.P2(2),'MarkerSize',8, ...
    'markeredgecolor','k','markerfacecolor','b','marker','o',...
    'ButtonDownFcn','topview(''electrode_ButtonDownFcn'',gcbo,[],guidata(gcbo),''P2'');');

if length(varargin)==1
    names = fieldnames(varargin{1});
    for k = 1:length(names)
        handles.config.(names{k}) = varargin{1}.(names{k});
    end
    
    if ~isempty(handles.config.Cwire);
        pos = handles.config.Cwire;
        handles.config.Cwire = [];
        for k = 1:size(pos,1)
            handles = add_apex(handles,pos(k,1:2),'Cwire');
        end
    end
    
    if ~isempty(handles.config.Pwire);
        handles.topview.current_apex(1:2) = {'Pwire', 0};
        pos = handles.config.Pwire;
        handles.config.Pwire = [];
        for k = 1:size(pos,1)
            handles = add_apex(handles,pos(k,1:2),'Pwire');
        end
    end
end

set(handles.Config_popup,'string',handles.config.type);

handles = update_topview(handles);

set_axis_limmits(handles);

% Update handles structure
guidata(hObject, handles);

% Make the GUI modal
set(handles.figure1,'WindowStyle','modal')


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


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

% The figure can be deleted now
delete(handles.figure1);

% --------------------------------------------------------------------
% --- Executes during object creation, after setting all properties.function C1_x_edit_CreateFcn(hObject, eventdata, handles)% hObject    handle to C1_x_edit (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    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --------------------------------------------------------------------
function C1_x_edit_Callback(hObject, eventdata, handles)% hObject    handle to C1_x_edit (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 C1_x_edit as text%        str2double(get(hObject,'String')) returns contents of C1_x_edit as a double
handles.config.C1(1) = str2num(get(hObject,'String'));
handles = update_topview(handles);
set_axis_limmits(handles);

handles.config.type = 'General Surface Array';
set(handles.Config_popup,'String', handles.config.type);

guidata(hObject, handles);% --------------------------------------------------------------------
% --- Executes during object creation, after setting all properties.function C1_y_edit_CreateFcn(hObject, eventdata, handles)if ispc    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --------------------------------------------------------------------
function C1_y_edit_Callback(hObject, eventdata, handles)handles.config.C1(2) = str2num(get(hObject,'String'));
handles = update_topview(handles);
set_axis_limmits(handles);

handles.config.type = 'General Surface Array';
set(handles.Config_popup,'String', handles.config.type);

guidata(hObject, handles);
% --------------------------------------------------------------------
% --- Executes during object creation, after setting all properties.function C1_z_edit_CreateFcn(hObject, eventdata, handles)if ispc    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --------------------------------------------------------------------
function C1_z_edit_Callback(hObject, eventdata, handles)handles.config.C1(3) = str2num(get(hObject,'String'));
handles = update_topview(handles);
set_axis_limmits(handles);

handles.config.type = 'General Surface Array';
set(handles.Config_popup,'String', handles.config.type);

guidata(hObject, handles);
% --------------------------------------------------------------------
% --- Executes during object creation, after setting all properties.function C2_x_edit_CreateFcn(hObject, eventdata, handles)if ispc    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --------------------------------------------------------------------
function C2_x_edit_Callback(hObject, eventdata, handles)handles.config.C2(1) = str2num(get(hObject,'String'));
handles = update_topview(handles);
set_axis_limmits(handles);

handles.config.type = 'General Surface Array';
set(handles.Config_popup,'String', handles.config.type);

guidata(hObject, handles);
% --------------------------------------------------------------------
% --- Executes during object creation, after setting all properties.function C2_y_edit_CreateFcn(hObject, eventdata, handles)if ispc    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --------------------------------------------------------------------
function C2_y_edit_Callback(hObject, eventdata, handles)handles.config.C2(2) = str2num(get(hObject,'String'));
handles = update_topview(handles);
set_axis_limmits(handles);

handles.config.type = 'General Surface Array';
set(handles.Config_popup,'String', handles.config.type);

guidata(hObject, handles);% --------------------------------------------------------------------
% --- Executes during object creation, after setting all properties.function C2_z_edit_CreateFcn(hObject, eventdata, handles)if ispc    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));

⌨️ 快捷键说明

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