Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Plot field lines of vector fields using streamslice

628 views
Skip to first unread message

PaulS Sochor

unread,
May 2, 2010, 4:32:04 PM5/2/10
to
I am currently working on a little script to visualize TE and TM modes in rectangular and circular waveguides and cavity resonators. I have 3 vector fields (Hx,Hy,Hz) for the magnetic field and 3 vector fields for the electric field (Ex,Ey,Ez) which makes my problem a 4 dimensional one.
I am getting satisfactory results with a combination of slice to plot slices showing the intensity of the electric and magnetic fields and streamslice to show the corresponding field lines within the planes.

My only problem is that streamslice plots field lines equidistant to each other. But since the intensity of electric and magnetic fields in one area is directly proportional to the density of its field lines, I would like to have more field lines in areas with higher intensity and less or no field lines in areas with little intensity.

Since you can access the vector coordinates of the lines produced by streamslice, my idea was just to remove a few to make the line density approximately corresponding to the field intensity. Though I had no luck with this yet.

Any help and suggestions are appreciated

us

unread,
May 2, 2010, 4:38:04 PM5/2/10
to
"PaulS Sochor" <magic...@hotmail.com> wrote in message <hrkng4$m75$1...@fred.mathworks.com>...

a few slices of ML code would help...

us

PaulS Sochor

unread,
May 2, 2010, 6:39:03 PM5/2/10
to
Sorry, here is some code which should explain my problem. The density of field lines is almost uniform. Going from the edge to the center the density of field lines should actually be decreasing.

a=100;
b=10;
c=100;
d=sqrt(a^2 + c^2);

T=0.3;

[X,Y,Z]=meshgrid(0:1:a, 0:1:b, 0:1:c);

Hx= (a/d)*sin((pi*X)/a).*cos((pi*Z)/c).*sin(pi*T);
Hy= zeros(size(X));
Hz= -(c/d)*cos((pi*X)/a).*sin((pi*Z)/c).*sin(pi*T);

W= sqrt(Hx.^2 + Hz.^2);

slice(X,Y,Z,W,[],[b],[]);

[hverts haverts]= streamslice(X,Y,Z,Hx,Hy,Hz,[],[b],[],1,'linear');
hlines= streamline([hverts haverts]);
set(hlines,'LineWidth',3,...
'Marker','.',...
'MarkerSize',3,...
'MarkerFaceColor','k',...
'Color','k')

view(0,0),axis([0 a 0 b 0 c])

0 new messages