How to plot Poynting vector by using values of matrices.

10 views (last 30 days)
Hi all, here i got the matrices of poynting vector components py and pz, which are 301*301 and attached as files, and i want to plot poynting vector by using py and pz. the code i utilized are as follow. But the picture (see attached image) looks not correct. anyone could help me? thanks very much. Note that the red arrow in the attached image is the propagation direction of wave, thus the poynting vector should also be in the same direction as the red arrow.
[Y Z]=meshgrid(-1:0.005:0.5);
Sy=gradient(Py(:,1:end),0.005);
Sz=gradient(Pz(1:end,:),0.005);
quiver(Y,Z,Sy,Sz,1,'w');
another way to get gradients:
[Y Z]=meshgrid(-1:0.005:0.5);
V_p=sqrt(Py.^2+Pz.^2);
[Sy,Sz]=gradient(V_p,0.005,0.005);
quiver(Y,Z,Sy,Sz,1,'w');
the poynting vectors of those two methods are indetical, and wrong.
  2 Comments
Geoff Hayes
Geoff Hayes on 30 Jul 2014
Hu - can you please verify that the above code and attachments work? I loaded the data via
load('Py.txt')
load('Pz.txt')
and then ran the first block of code (I needed to add a closing bracket the line of Sz). The Sz matrix contained only Inf values. I then tried the second block of code, and the figure appeared as all white with nothing drawn on it.
Hu Jinbing
Hu Jinbing on 31 Jul 2014
hi, Geoff, thanks for your responding. i am sorry for the lose of the right bracklet in the line of Sz. And i have checked that there is no problem about the values in Py-matrix and pz-matrix.Besides,the problem about plotting poynting vector has beem solved. the code for basic algebra to get the magnitude and direction are as follow:
[Y,Z]=meshgrid(-1:0.005:0.5);
Py=load('Py.txt')
Pz=load('Pz.txt')
P=Py+1i*Pz;
v_P=abs(P);
nordir=P./v_P;
nordir_y=real(nordir);
nordir_z=imag(nordir);
pcolor(Y,Z,v_P);hold on;
quiver(Y,Z,nordir_y,nordir_z,0.5,'k');
hold off;

Sign in to comment.

Answers (0)

Categories

Find more on View and Analyze Simulation Results in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!