Plot field lines of vector fields using streamslice

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  
0
PaulS
5/2/2010 8:32:04 PM
comp.soft-sys.matlab 209407 articles. 11 followers. lunamoonmoon (258) is leader. Post Follow

2 Replies
2793 Views

Similar Articles

[PageSpeed] 1

"PaulS Sochor" <magical_jp@hotmail.com> wrote in message <hrkng4$m75$1@fred.mathworks.com>...
> 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  

a few slices of ML code would help...

us
0
us
5/2/2010 8:38:04 PM
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
PaulS
5/2/2010 10:39:03 PM
Reply: