Overlay plots of different angles of incidence.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
AdomPadom
il 10 Gen 2023
Modificato: Mathieu NOE
il 20 Gen 2023
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
Risposta accettata
Mathieu NOE
il 10 Gen 2023
Modificato: Mathieu NOE
il 20 Gen 2023
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
0 Commenti
Più risposte (1)
Alan Stevens
il 10 Gen 2023
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
0 Commenti
Vedere anche
Categorie
Scopri di più su Graphics Performance in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!