How to plot Poynting vector by using values of matrices.

11 Ansichten (letzte 30 Tage)
Hu Jinbing
Hu Jinbing am 30 Jul. 2014
Bearbeitet: Hu Jinbing am 31 Jul. 2014
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 Kommentare
Geoff Hayes
Geoff Hayes am 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 am 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;

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu View and Analyze Simulation Results finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by