pcolor function axes switch

3 次查看(过去 30 天)
Mattia Sospetti
Mattia Sospetti 2020-5-20
clc
clear
epsilon0=8.9*10^(-12);
epsilon1=1;
epsilon2=9;
eta0 = 377;
eta1 = eta0/(sqrt(epsilon1));
eta2 = eta0/(sqrt(epsilon2));
ro=(eta2-eta1)/(eta2+eta1);
tau=1+ro;
mu = 1.2566*10^(-6);
w = 2*pi*300*10^6;
beta1 = w*sqrt(mu*epsilon0*epsilon1); %fase
beta2 = w*sqrt(mu*epsilon0*epsilon2);
tetai=30;
tetar=tetai;
tetat= asin(sqrt(epsilon1)*sin(tetai)/sqrt(epsilon2));%Snell;
PERIODO=1/(300*10^6);
dt = PERIODO / ( 100 );
tempo = [ 0 : dt : PERIODO * 3];
pluto=linspace(0,3,100);
[x,z]=meshgrid(pluto,pluto); %invertito x e z
%Intensità campo elettrico
Ey=3;
hold on
axis ([0,200,0,200]) % i 4 valori sono xmin, xmax, ymin, ymax
for i = 1:numel(tempo) %numel="number of elements"
t = tempo(i);
Eiy=Ey*[cos(w*t-beta1*(-x*sin(tetai)+z*cos(tetai)))];
Hix=-(Ey/eta1)*(cos(tetai))*[cos(w*t-beta1*(-x*sin(tetai)+z*cos(tetai)))];
Ery=ro*Ey*[cos(w*t-beta1*(x*sin(tetar)-z*cos(tetar)))];
Hrx=ro*(Ey/eta1)*cos(tetar)*[cos(w*t+beta1*(-x*sin(tetar)-z*cos(tetar)))];
Ety=tau*Ey*[cos(w*t-beta2*(x*sin(tetat)+z*cos(tetat)))];
Htx=-tau*(Ey/eta2)*cos(tetat)*[cos(w*t-beta2*(x*sin(tetat)+z*cos(tetat)))];
concat_img=[Eiy+Hix Ety+Htx; Ery+Hix Ety+Htx];
xlabel('asse x')
ylabel('asse y')
zlabel('asse z')
%concat_img2=[Ety+Htx;Ery+Hrx];
pcolor(concat_img);
shading interp;
%pcolor(concat_img2);
drawnow
M(i)=getframe;
%drawnow
%pcolor(Eiy+Hix);
%pcolor(Ery+Hrx);
%M(i)=getframe;
end
I need to plot with pcolor an oblique incidence in the x-z plane. The problem is that the pcolor function creates the plot in the x-y plane.
How can i switch the axes?

回答(2 个)

darova
darova 2020-5-20
编辑:darova 2020-5-20
  • use meshgrid to create X, Y and Z matrices
  • use surf with cdata property to assign colors
Example
[X,Z] = meshgrid(-3:.5:3);
Y = X*0;
C = hypot(X,Z);
surf(X,Y,Z,'cdata',C)
Succeeded
  1 个评论
Mattia Sospetti
Mattia Sospetti 2020-5-20
No, i'm sorry but it didn't help. As you can see in the first raws of the code i tried to define the x-z plane as i wanted to plot the propagation into the y direction, but the pcolor is on the x-y plane

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2020-5-20
Create a hgtransform group. When you pcolor(), set its Parent to be the hgtransform group. Use makehgtform to build a transform matrix that rotates the axes as required. Set that as the Matrix of the hgtransform group.

类别

Help CenterFile Exchange 中查找有关 Object Containers 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by