How to plot Poynting vector by using values of matrices.

14 vues (au cours des 30 derniers jours)
Hu Jinbing
Hu Jinbing le 30 Juil 2014
Modifié(e) : Hu Jinbing le 31 Juil 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 commentaires
Geoff Hayes
Geoff Hayes le 30 Juil 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 le 31 Juil 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;

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur View and Analyze Simulation Results dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by