How to plot shaded rectangles in between band gaps?
古いコメントを表示
How to add the rectangle shaded boxes in between the band gaps. Ref image attached in end of the page.
clc
close all
c = 3e8;
d1 = 0.4;d2 = 0.6;d = d1 + d2;
n1 = sqrt(12);n2 = 1;
lambda = linspace(400e-3,800e-3, 10000000);
D1 = (2*pi*n1*d1)./lambda;D2 = (2*pi*n2*d2)./lambda;
RHS = cos(D1).*cos(D2) - 0.5*(n1^2+n2^2)/(n1*n2) * sin(D1) .*sin(D2);
kz1 =acos(RHS)/d;
IDX1 = -1<RHS<1;
kz1(IDX1)=nan;
kz=real(kz1);
kz(kz==0)=nan;
figure(1)
plot(kz,lambda,'r')
xlabel('wave vector')
ylabel('frequency')

3 件のコメント
Rik
2023 年 8 月 15 日
What have you tried so far? The patch function should do what you need.
GULZAR
2023 年 8 月 15 日
Star Strider
2023 年 8 月 15 日
The obvious solution is the patch function. I tried that, however I could not figure out how your code works.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

