How to plot transcendental equation?
12 ビュー (過去 30 日間)
古いコメントを表示
Vaswati Biswas
2021 年 11 月 5 日
コメント済み: Vaswati Biswas
2021 年 11 月 7 日
I want to plot neff vs lambda graph following a analytical expression. But when I run my code it doesnot show me any error but also no graphical image is shown.Here I want to calculate the values of neff by varying the lambda following the expression given below.
My code is given below:
clc
clear all
close all
nf= 1.3;
ns=1.5;
nc=1;
rho=1;
hf=1.5;
lambda = 100:1:350;
m=1;
syms func(lambda,neff)
phi_c = - atand((nf/nc)^(2*rho)*sqrt ((neff^2-nc^2)/(nf^2-neff^2)));
phi_s = -atand((nf/ns)^(2*rho)*sqrt ((neff^2-ns^2)/(nf^2-neff^2)));
func(lambda,neff) = @(lambda,neff)(((2*pi/lambda)*(sqrt(nf^2-neff^2)*hf))+ phi_c + phi_s -(m*pi))==0;
ezplot(func)
Myouput is
How can I resolve the Problem? Kindly help.
1 件のコメント
Paul
2021 年 11 月 5 日
Are you sure that phi_c/s should be using atand() and not atan() ?
Are there any values of neff for which phi_c and phi_s are both real? It looks like phi_c is real for nc < abs(neff) < nf (1 < abs(neff) < 1.3) but those values of neff result in neff^2 - ns^2 < 0.
採用された回答
Sulaymon Eshkabilov
2021 年 11 月 5 日
Here is how it can be solved and plotted:
clc
clearvars
close all
nf= 1.3;
ns=1.5;
nc=1;
rho=1;
hf=1.5;
lambda = 100:350;
m=1;
syms neff
phi_c = - atand((nf/nc)^(2*rho)*sqrt ((neff^2-nc^2)/(nf^2-neff^2)));
phi_s = -atand((nf/ns)^(2*rho)*sqrt ((neff^2-ns^2)/(nf^2-neff^2)));
NEFF = zeros(size(lambda));
for ii=1:numel(lambda)
Eqn = (((2*pi./lambda(ii))*(sqrt(nf^2-neff^2)*hf))+ phi_c + phi_s -(m*pi))==0;
NEFF(ii)=double(vpasolve(Eqn));
end
%%
plot(lambda, real(NEFF), 'r-o', 'DisplayName', 'neff: real part'), hold on
plot(lambda, imag(NEFF), 'b-d', 'DisplayName', 'neff: imag part'), hold on
legend; grid on
5 件のコメント
Sulaymon Eshkabilov
2021 年 11 月 7 日
Note that you're calling a different variable name NEFF1(ii)=double(vpasolve(Eqn)). That should be NEFF(ii)=double(vpasolve(Eqn))
The code does not have any problem with nf=2 and runs ok. It produces solutions correctly.
その他の回答 (1 件)
Sulaymon Eshkabilov
2021 年 11 月 7 日
clc
clearvars
close all
nf= 1.3;
ns=1.5;
nc=1;
rho=1;
hf=2;
lambda = 100:350;
m=1;
syms neff
phi_c = - atand((nf/nc)^(2*rho)*sqrt ((neff^2-nc^2)/(nf^2-neff^2)));
phi_s = -atand((nf/ns)^(2*rho)*sqrt ((neff^2-ns^2)/(nf^2-neff^2)));
NEFF = zeros(size(lambda));
for ii=1:numel(lambda)
Eqn = (((2*pi./lambda(ii))*(sqrt(nf^2-neff^2)*hf))+ phi_c + phi_s -(m*pi))==0;
NEFF(ii)=double(vpasolve(Eqn));
end
%%
plot(lambda, real(NEFF), 'r-o', 'DisplayName', 'neff: real part'), hold on
plot(lambda, imag(NEFF), 'b-d', 'DisplayName', 'neff: imag part'), hold on
legend; grid on
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Dialog Boxes についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!