Professional Documents
Culture Documents
Particleinb E Gui.m PDF
Particleinb E Gui.m PDF
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
%close all;
%clear all;
clc;
set(handles.vx,'Value',0);
set(handles.vy,'Value',0);
set(handles.vz,'Value',0);
set(handles.x,'Value',-10);
set(handles.y,'Value',0);
set(handles.z,'Value',0);
set(handles.Bx,'Value',0);
set(handles.By,'Value',-6);
set(handles.Bz,'Value',0);
set(handles.Ex,'Value',0)
set(handles.Ey,'Value',0)
set(handles.Ez,'Value',2)
set(handles.q,'Value',1);
set(handles.m,'Value',5);
% --- Outputs from this function are returned to the command line.
function varargout = particleinB_E_gui_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)
u_q=B(1)*ones(size(x_q));
v_q=B(2)*ones(size(x_q));
w_q=B(3)*ones(size(x_q));
quiver3(x_q,y_q,z_q,u_q,v_q,w_q);
hold all;
u_q=E(1)*ones(size(x_q));
v_q=E(2)*ones(size(x_q));
w_q=E(3)*ones(size(x_q));
quiver3(x_q,y_q,z_q,u_q,v_q,w_q);
legend('B','E');
rotate3d(handles.axes,'on');
plot3(r0(1),r0(2),r0(3),'*m','MarkerSize',9,'LineWidth',2);
y0 = [r0; v0];
f = @(t,y) [y(4:6); (q/m)*cross(y(4:6),B)+E];
[t,y] = ode23t(f,tspan,y0);
z_z = get(handles.stop,'String');
if z_z == 'Stoped'
break;
end
end
guidata(hObject, handles);