How to plot Poynting vector by using values of matrices.
14 views (last 30 days)
Show older comments
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
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.
Answers (0)
See Also
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!