I am currently working on my bachelor thesis, where I am calculating trajectory of electrons and ions in Hall Effect Ion Thruster. However, to be sure what I am calculating, I need to know how does the electromagnetic field look like.

I already have working code for visualization of electromagnetic field using streamslice, however I would like to take it to the next level.

I have created coordinates $x,$ $y$ and $z$ through meshgrid and computated magnetic field, which is set of not really pretty equations. Electric field points only towards the $z$ direction.

Here is the snappet of code that is generating picture below:

% Magnetic field
plot_field = streamslice(x,y,z,Bx,By,Bz,0.02,0.02,0);

% Electric field
hold on;
hold off;

% Plot of discharge chamber
[x_ch, y_ch, z_ch] = cylinder(0.4,40);
z_ch(1,:) = -0.2;
z_ch(2,:) = 0.2;

hold on;
plot_ch = surf(x_ch,y_ch,z_ch);
hold off;

This code generates the following,

Plot of magnetic field line slices


I would like to create streamslice of the magnetic field in various degrees slope (let's say $45$), so I could see how does the field looks like not only when intersecting magnetic dipoles, but also in other locations. That would be great for study of particle motion.


1 Answer 1


It is possible to draw a streamslice slicing using non-planar or at arbitrary angle. You can use rotate command to rotate your slicing plane(s). Your plot_field object can be modified by adding several lines

slicing = surf(linspace(-1,1,10),linspace(-1,1,10),zeros(10));
% third input: rotating angle
% second input: the vector to which you are rotating your data with respect
xs = get(slicing,'XData');
ys = get(slicing,'YData');
zs = get(slicing,'ZData');
plot_field = streamslice(x,y,z,Bx,By,Bz,xs,ys,zs);

Also contourslice is another my own favorite to visualize electromagnetic field: http://www.mathworks.com/help/matlab/ref/contourslice.html

If you know how to use VTK, then you can export your 3D vector data to a vtk file using: http://www.mathworks.com/matlabcentral/fileexchange/34310-matlab-3d-vectors-to-paraview-via-binary-vtk-file

Then you could use software like Paraview to visualize vector field as you like, for example, slicing at $45^{\circ}$ degree of the box like you said (I used the data of my own from a dielectric with a cavity Maxwell pde):



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.