- use meshgrid to create X, Y and Z matrices
- use surf with cdata property to assign colors
pcolor function axes switch
17 views (last 30 days)
Show older comments
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?
0 Comments
Answers (2)
Walter Roberson
on 20 May 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.
0 Comments
See Also
Categories
Find more on Axes Appearance in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!