pcolor function axes switch

조회 수: 19 (최근 30일)
Mattia Sospetti
Mattia Sospetti 2020년 5월 20일
답변: Walter Roberson 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에서 Axes Appearance에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by