How to create an array?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Vaswati Biswas
el 10 de Nov. de 2021
Editada: Rena Berman
el 19 de Nov. de 2021
I want to calculate the value of S by varying the hf but it only gives me a point. My code is given below. Kindly help
clc
clearvars
close all
nf=2.1511;
ns=1.5157;
nc=1.3279;
rho=1;
lambda = 532.3;
m= 0;
NEFF = [];
S= [];
syms neff
%NEFF = zeros(size(hf));
for hf=linspace(100,130,5)
NEFF = zeros(size(hf));
phi_c = -atan((nf/nc)^(2*rho)*sqrt ((neff.^2-nc^2)/(nf^2-neff.^2)));
phi_s = -atan((nf/ns)^(2*rho)*sqrt ((neff.^2-ns^2)/(nf^2-neff.^2)));
Eqn = ((((2*pi./lambda)*(sqrt(nf^2-neff.^2)*hf))+(-atan((nf/nc).^(2*rho)*sqrt ((neff.^2-nc^2)/(nf^2-neff.^2))))+ (-atan((nf/ns).^(2*rho)*sqrt ((neff.^2-ns^2)/(nf^2-neff.^2)))) -(m*pi)))==0;
assume(neff>0)
NEFF= vpasolve(Eqn, neff, [0, 5]);
%NEFF(ii)= abs(NEFF1(ii));
deltaz_c = (lambda./2*pi).*(NEFF.^2-nc^2).^(-0.5).*((NEFF./nf).^2+(NEFF./(nc.^2)-1)).^(-rho);
deltaz_s = (lambda./2*pi).*(NEFF.^2-ns^2).^(-0.5).*((NEFF./nf).^2+(NEFF./(ns.^2)-1)).^(-rho);
heff = deltaz_c+ deltaz_s+hf;
P_c = ((nf.^2-NEFF.^2)./(nf^2-nc^2)).*(deltaz_c./heff);
S = (NEFF./nc).* P_c.*((2*(NEFF./nc).^2)-1).^rho;
end
plot(hf, S, 'b-d', 'DisplayName', 'neff: imag part'), hold on
%xlim([850 1850])
2 comentarios
Cris LaPierre
el 11 de Nov. de 2021
I want to calculate the value of S by varying the hf but it only gives me a point. My code is given below. Kindly help
clc
clearvars
close all
nf=2.1511;
ns=1.5157;
nc=1.3279;
rho=1;
lambda = 532.3;
m= 0;
NEFF = [];
S= [];
syms neff
%NEFF = zeros(size(hf));
for hf=linspace(100,130,5)
NEFF = zeros(size(hf));
phi_c = -atan((nf/nc)^(2*rho)*sqrt ((neff.^2-nc^2)/(nf^2-neff.^2)));
phi_s = -atan((nf/ns)^(2*rho)*sqrt ((neff.^2-ns^2)/(nf^2-neff.^2)));
Eqn = ((((2*pi./lambda)*(sqrt(nf^2-neff.^2)*hf))+(-atan((nf/nc).^(2*rho)*sqrt ((neff.^2-nc^2)/(nf^2-neff.^2))))+ (-atan((nf/ns).^(2*rho)*sqrt ((neff.^2-ns^2)/(nf^2-neff.^2)))) -(m*pi)))==0;
assume(neff>0)
NEFF= vpasolve(Eqn, neff, [0, 5]);
%NEFF(ii)= abs(NEFF1(ii));
deltaz_c = (lambda./2*pi).*(NEFF.^2-nc^2).^(-0.5).*((NEFF./nf).^2+(NEFF./(nc.^2)-1)).^(-rho);
deltaz_s = (lambda./2*pi).*(NEFF.^2-ns^2).^(-0.5).*((NEFF./nf).^2+(NEFF./(ns.^2)-1)).^(-rho);
heff = deltaz_c+ deltaz_s+hf;
P_c = ((nf.^2-NEFF.^2)./(nf^2-nc^2)).*(deltaz_c./heff);
S = (NEFF./nc).* P_c.*((2*(NEFF./nc).^2)-1).^rho;
end
plot(hf, S, 'b-d', 'DisplayName', 'neff: imag part'), hold on
%xlim([850 1850])
Respuesta aceptada
Cris LaPierre
el 10 de Nov. de 2021
See the examples on the for loop documentation page. You can also learn how to do this interactively in Ch 12 of MATLAB Onramp.
Más respuestas (0)
Ver también
Categorías
Más información sobre Number Theory en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!