For plot V vs b (normalized frequency vs normalized propagation constant), anyone please can u help me to know how can i write or add function in this program code?

clear all;
close all;
Mx = 129; % number of discretization points in x direction
My = Mx; % number of discretization points in y direction
mesh_points.x = linspace(-10,10,Mx)*1e-6; % mesh grid points in x direction
mesh_points.y = linspace(-10,10,My)*1e-6; % mesh grid points in y direction
[X,Y] = ndgrid(mesh_points.x, mesh_points.y); % Define x-y grid
% Define waveguide geometry
n1 = 1.455; % core refractive index
n2 = 1.45; % cladding refractive index
a = 4.5e-6; % core radius
N = n2*ones(Mx,My);
% circular step-index optical waveguide
N((X.^2 + Y.^2) <= a^2) = n1;
options.mode = 'scalar'; % use scalar computation mode
options.discretization = 'equidistant'; % use equidistant discretization
k = 50; % maximum number of eigenmodes to be computed
V = 5; % normalized frequency
lambda = (2*pi*a*sqrt(n1^2-n2^2))./V; %wavelength
[phi_eigs, neff] = eig_v11(lambda, N, mesh_points, k, options);
neff=n2; % Effective refractive indices of eigenmodes
mode_count = sum(neff > n2);
subplot_dim = [3 2];
k = 30;
V_vec = linspace(0,10,50);
lambda_vec = (2*pi*a*sqrt(n1^2-n2^2))./V_vec;
neff_matrix = zeros(k, length(lambda_vec));
for i = 1:length(lambda_vec)
% disp_msg(['Iteration: ' num2str(i) '/' num2str(length(lambda_vec))]);
lambda = lambda_vec(i);
[phi_eigs, neff] = eig_v11(lambda, N, mesh_points, k, options);
neff_matrix(:,i) = neff;
end
B = (real(neff_matrix.')-n2)/(n1-n2);% Normalized propagation constants of eigenmodes
subplot_dim = [3 2];
plot_eigenmodes(X, Y, phi_eigs, neff, mode_count, subplot_dim, ...
[1 1.5]*500, B);
figure;
plot(V_vec,B);
xlim([min(V_vec) max(V_vec)]);
ylim([0 1]);
title('Dispersion Relation of a Circular Waveguide');
xlabel('V');
ylabel('B');

Answers (1)

ATLAB AnswersToggle Sub Navigation For plot V vs b (normalized frequency vs normalized propagation constant), anyone please can u help me to know how can i write or add function in this program code? 24 views (last 30 days) Shaikat Majumder Shaikat Majumder on 17 May 2020 ⋮ Edited: Shaikat Majumder on 17 May 2020 clear all; close all; Mx = 129; % number of discretization points in x direction My = Mx; % number of discretization points in y direction mesh_points.x = linspace(-10,10,Mx)*1e-6; % mesh grid points in x direction mesh_points.y = linspace(-10,10,My)*1e-6; % mesh grid points in y direction [X,Y] = ndgrid(mesh_points.x, mesh_points.y); % Define x-y grid % Define waveguide geometry n1 = 1.455; % core refractive index n2 = 1.45; % cladding refractive index a = 4.5e-6; % core radius N = n2*ones(Mx,My); % circular step-index optical waveguide N((X.^2 + Y.^2) <= a^2) = n1; options.mode = 'scalar'; % use scalar computation mode options.discretization = 'equidistant'; % use equidistant discretization k = 50; % maximum number of eigenmodes to be computed V = 5; % normalized frequency lambda = (2*pi*a*sqrt(n1^2-n2^2))./V; %wavelength [phi_eigs, neff] = eig_v11(lambda, N, mesh_points, k, options); neff=n2; % Effective refractive indices of eigenmodes mode_count = sum(neff > n2); subplot_dim = [3 2]; k = 30; V_vec = linspace(0,10,50); lambda_vec = (2*pi*a*sqrt(n1^2-n2^2))./V_vec; neff_matrix = zeros(k, length(lambda_vec)); for i = 1:length(lambda_vec)
% disp_msg(['Iteration: ' num2str(i) '/' num2str(length(lambda_vec))]); lambda = lambda_vec(i); [phi_eigs, neff] = eig_v11(lambda, N, mesh_points, k, options); neff_matrix(:,i) = neff; end B = (real(neff_matrix.')-n2)/(n1-n2);% Normalized propagation constants of eigenmodes subplot_dim = [3 2]; plot_eigenmodes(X, Y, phi_eigs, neff, mode_count, subplot_dim, ... [1 1.5]*500, B); figure; plot(V_vec,B); xlim([min(V_vec) max(V_vec)]); ylim([0 1]); title('Dispersion Relation of a Circular Waveguide'); xlabel('V'); ylabel('B');

Asked:

on 17 May 2020

Answered:

on 3 Jul 2022

Community Treasure Hunt

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

Start Hunting!