Overlay plots of different angles of incidence.
3 ビュー (過去 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
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
0 件のコメント
その他の回答 (1 件)
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!