pcolor function axes switch

17 vues (au cours des 30 derniers jours)
Mattia Sospetti
Mattia Sospetti le 20 Mai 2020
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?

Réponses (2)

darova
darova le 20 Mai 2020
Modifié(e) : darova le 20 Mai 2020
  • 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 commentaire
Mattia Sospetti
Mattia Sospetti le 20 Mai 2020
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

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 20 Mai 2020
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.

Catégories

En savoir plus sur Axes Appearance dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by