Why does disappear my plot when i zoom in in the interest zone?
8 views (last 30 days)
Show older comments
This is my code
% CONSTANTS
mu=4*pi*10^-7;
c=3E8;
d=6E-6;
n1=1.45125;
n0=1.44725;
n12=n1^2;
n02=n0^2;
n=(n0/n1)^2;
p=2*pi/c;
NA=sqrt((n1^2)-(n0^2));
% DEFINITION OF MY FUNCTION
beta1= @(k,b) (1/c)*((b)+((k.*n02*(n12-b.^2)*sec(k.*sqrt(n12-b.^2))^2)/(((b.*tan(k.*sqrt(n12-b.^2)))/(sqrt(n12-b.^2)))-(k.*b.*sec(k.*sqrt(n12-b.^2))^2)-((b.*n12)/(sqrt(b.^2-n02))))));
% REPRESENTATION
fimplicit(beta1, [0 20*pi 0 500])
when i zoom in the interest zone (x (0,10),y(0,10), the plot disappears, why does this happen?
0 Comments
Answers (1)
Walter Roberson
on 4 Dec 2022
Edited: Walter Roberson
on 4 Dec 2022
Your code assumes that there are continuous solutions for at least a subrange of [0 20*pi]
% CONSTANTS
mu=4*pi*10^-7;
c=3E8;
d=6E-6;
n1=1.45125;
n0=1.44725;
n12=n1^2;
n02=n0^2;
n=(n0/n1)^2;
p=2*pi/c;
NA=sqrt((n1^2)-(n0^2));
% DEFINITION OF MY FUNCTION
syms b k
beta1 = matlabFunction( (1/c)*((b)+((k.*n02*(n12-b.^2)*sec(k.*sqrt(n12-b.^2))^2)/(((b.*tan(k.*sqrt(n12-b.^2)))/(sqrt(n12-b.^2)))-(k.*b.*sec(k.*sqrt(n12-b.^2))^2)-((b.*n12)/(sqrt(b.^2-n02)))))), 'vars', [k,b])
Kvals = linspace(0, 6, 500).';
Bs = arrayfun(@(k) vpasolve(beta1(k,b),b), Kvals);
plot(Kvals, [real(Bs), imag(Bs)]); yline(0);
legend({'real', 'imaginary'})
For the range up to 6, the only solutions are roughly 10 individual points where the imaginary part of the vpasolve() are 0. Not a continuous line, just individual points
Kvals2 = linspace(6, 50*pi, 250).';
Bs2 = arrayfun(@(k) vpasolve(beta1(k,b),b), Kvals2);
plot(Kvals2, [real(Bs2), imag(Bs2)]); yline(0);
legend({'real', 'imaginary'})
Above 6 there appear to be a number of individual-point solutions.
2 Comments
Walter Roberson
on 4 Dec 2022
One can make the hypothesis that each solution should be "close to" the previous one.
% CONSTANTS
mu=4*pi*10^-7;
c=3E8;
d=6E-6;
n1=1.45125;
n0=1.44725;
n12=n1^2;
n02=n0^2;
n=(n0/n1)^2;
p=2*pi/c;
NA=sqrt((n1^2)-(n0^2));
% DEFINITION OF MY FUNCTION
syms b k
beta1 = matlabFunction( (1/c)*((b)+((k.*n02*(n12-b.^2)*sec(k.*sqrt(n12-b.^2))^2)/(((b.*tan(k.*sqrt(n12-b.^2)))/(sqrt(n12-b.^2)))-(k.*b.*sec(k.*sqrt(n12-b.^2))^2)-((b.*n12)/(sqrt(b.^2-n02)))))), 'vars', [k,b])
Kvals = linspace(0, 6, 500).';
Kvals(1) = []; %0 is a special case
N = length(Kvals);
Bs = zeros(N,1);
guess = 1+1i;
for idx = 1 : N
sol = vpasolve(beta1(Kvals(idx), b), guess);
if isempty(sol)
Bs(idx) = nan;
else
Bs(idx) = sol;
guess = sol;
end
end
plot(Kvals, [real(Bs), imag(Bs)]); yline(0);
legend({'real', 'imaginary'})
The solutions for the fimplicit are the locations where the orange-ish line crosses 0 -- only two points in this range.
Why is the previous plot so messy then? Well that means there are multiple point-wise solutions, and that should perhaps be investigated more -- but even so, the solutions are still point-wise, not continuous curves.
See Also
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!