MATLAB Answers

different plots on different levels of zooming

1 view (last 30 days)
Shlok Vaibhav Singh
Shlok Vaibhav Singh on 17 Dec 2019
Answered: Kavya Vuriti on 31 Mar 2020
I am running this code on MatLab:
function main
fimplicit (@(x,y)f(x,y),[2 5])
end
function fun = f(x,y)
nc=1.45; %cladding
nf=1.5;
ns=1.4; %substrate
h=5; %width of waveguide
kappa=sqrt(x^2*nf^2-y.^2);
gammas=sqrt(y^2-x^2*ns^2);
gammac=sqrt(y^2-x^2*nc^2);
z=sin(h.*kappa);
%TE mode
fun=z.*(kappa.^2-gammas.*gammac)-cos(h.*kappa).*(gammac+gammas).*kappa;
end
I got: (notice the wavy top line and dotted lower line)
Then I zoomed in around (2.5,3.5): (Notice the waves disappears)
Again I zoomed out and in again: (notice only staright lines remain):
1) Why am I getting such erratic behaviour.
2) What can be done to correct this since I need graphs for college work and cant use these.
Thanks !

  0 Comments

Sign in to comment.

Answers (1)

Kavya Vuriti
Kavya Vuriti on 31 Mar 2020
Hi,
While using fimplicit function, the plot depends on the number of evaluation points per direction. This property is termed as 'MeshDensity' with 151 as default value. Changing this value can give you the desired plot. This can be set either by using property inspector or can be given as a 'Name-Value' pair to fimplicit function.
The graphics issue with zoom may be due to older graphics hardware or outdated graphics drivers. By default MATLAB graphics uses hardware accelerated implementation. This may cause issues when graphic drivers are outdated. This issues can be resolved by updating graphics drivers or by changing to software implementation by using following command:
>> opengl('save', 'software');
Restart MATLAB and check if the implementation is changed by using the following command:
>> opengl info
For more information, you can refer following links:
Hope this helps!!

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!