Overlay plots of different angles of incidence.

2 次查看(过去 30 天)
I'm trying to plot the reflectivity of a grating over a range of frequencies and repeat this plot when changing the angle of incidence. My current code does plot the reflectivity at different angles but does so in seperate figures.
The end goal is something similar to the image. But using 3 axes rather than 2.
clear all
c = 600;
l = 300;
u = 800;
for a = 0:10:40
p = 1000;
s = (u-l)/p;
Frequency = zeros(1,p);
Reflectivity = zeros(1,p);
x = 1;
for range = l:s:u
y = (2*pi/range)*(c/4);
A = [1,1;1,-1];
B = [1,1;2,-2];
C = [1,1;4,-4];
P = [exp(-j*y*cosd(a)),0;0,exp(j*y*cosd(a))];
G = P*(B\C)*P*(C\B);
M = (A\B)*(G^3)*P*(G^3)*P*(B\A);
E1 = M(2,1)/M(1,1);
E2 = (abs(E1)^2);
Reflectivity(x) = E2;
Frequency(x) = range;
x = x+1;
end
figure;
grid on
[Fr,In] = meshgrid(Frequency,a);
plot3(Fr,In,Reflectivity')
xlabel('Frequency')
ylabel('Angle of Incidence')
zlabel('Reflectivity')
end

采纳的回答

Mathieu NOE
Mathieu NOE 2023-1-10
编辑:Mathieu NOE 2023-1-20
hello
a very simple modification of your code
create one figure and use hold on to overlay the next plots
% YOUR INIT SECTION HERE
figure(1);
grid on
hold on
xlabel('Frequency')
ylabel('Angle of Incidence')
zlabel('Reflectivity')
for Incident = 0:10:30 %ANGLE OF INCIDENCE
% YOUR MAIN CODE AS BEFORE HERE
%
%
%CHARTS
end
[Fr,In] = meshgrid(Frequency,Incident);
plot3(Fr,In,Reflectivity')
end

更多回答(1 个)

Alan Stevens
Alan Stevens 2023-1-10
Remove the word figure and add hold on after the plot
grid on
[Fr,In] = meshgrid(Frequency,Incident);
plot3(Fr,In,Reflectivity')
xlabel('Frequency')
ylabel('Angle of Incidence')
zlabel('Reflectivity')
hold on

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by