function varargout = diandianhe(varargin)
% DIANDIANHE MATLAB code for diandianhe.fig
% DIANDIANHE, by itself, creates a new DIANDIANHE or raises the existing
% singleton*.
%
% H = DIANDIANHE returns the handle to a new DIANDIANHE or the handle to
% the existing singleton*.
%
% DIANDIANHE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DIANDIANHE.M with the given input arguments.
%
% DIANDIANHE('Property','Value',...) creates a new DIANDIANHE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before diandianhe_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to diandianhe_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 diandianhe
% Last Modified by GUIDE v2.5 14-Apr-2023 23:37:18
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @diandianhe_OpeningFcn, ...
'gui_OutputFcn', @diandianhe_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 diandianhe is made visible.
function diandianhe_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 diandianhe (see VARARGIN)
% Choose default command line output for diandianhe
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
clc;
%初始值设定
global Q1 Q2 Q3 Q4;
Q1=1;Q2=1;Q3=1;Q4=1;%%初始化电荷量;
global x1 x2 x3 x4;
x1=-2;x2=2;x3=0;x4=0;%%初始化x的位置;
global y1 y2 y3 y4;
y1=0;y2=0;y3=2;y4=-2;%%初始化y的位置;
global scale1 num1;
num1=1;
scale1=1;
set(handles.radiobutton1,'value',1);%1#
set(handles.radiobutton2,'value',0);%2#
set(handles.radiobutton3,'value',0);%3#
set(handles.radiobutton4,'value',0);%4#
set(handles.radiobutton7,'value',1);%2D
set(handles.radiobutton8,'value',0);%3D
set(handles.edit6,'string',num2str(x1));
set(handles.edit7,'string',num2str(y1));
set(handles.edit8,'string',num2str(Q1));
% UIWAIT makes diandianhe wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = diandianhe_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 radiobutton7.
function radiobutton7_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton7
set(handles.radiobutton7,'value',1);
set(handles.radiobutton8,'value',0);
pushbutton1_Callback(hObject, eventdata, handles)
% --- Executes on button press in radiobutton8.
function radiobutton8_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton8
set(handles.radiobutton8,'value',1);
set(handles.radiobutton7,'value',0);
pushbutton1_Callback(hObject, eventdata, handles)
% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton1
set(handles.radiobutton1,'value',1);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',0);
set(handles.radiobutton4,'value',0);
global x1 y1 Q1;
set(handles.edit6,'string',num2str(x1));
set(handles.edit7,'string',num2str(y1));
set(handles.edit8,'string',num2str(Q1));
% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton2
set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',1);
set(handles.radiobutton3,'value',0);
set(handles.radiobutton4,'value',0);
global x2 y2 Q2;
set(handles.edit6,'string',num2str(x2));
set(handles.edit7,'string',num2str(y2));
set(handles.edit8,'string',num2str(Q2));
% --- Executes on button press in radiobutton3.
function radiobutton3_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton3
set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',1);
set(handles.radiobutton4,'value',0);
global x3 y3 Q3;
set(handles.edit6,'string',num2str(x3));
set(handles.edit7,'string',num2str(y3));
set(handles.edit8,'string',num2str(Q3));
% --- Executes on button press in radiobutton4.
function radiobutton4_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton4
set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',0);
set(handles.radiobutton4,'value',1);
global x4 y4 Q4;
set(handles.edit6,'string',num2str(x4));
set(handles.edit7,'string',num2str(y4));
set(handles.edit8,'string',num2str(Q4));
function edit6_Callback(hObject, eventdata, handles)
% hObject handle to edit6 (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 edit6 as text
% str2double(get(hObject,'String')) returns contents of edit6 as a double
global x1 x2 x3 x4;
if get(handles.radiobutton1,'value')
x1=str2num(get(handles.edit6,'string'));
elseif get(handles.radiobutton2,'value')
x2=str2num(get(handles.edit6,'string'));
elseif get(handles.radiobutton3,'value')
x3=str2num(get(handles.edit6,'string'));
elseif get(handles.radiobutton4,'value')
x4=str2num(get(handles.edit6,'string'));
end
pushbutton1_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles e