Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

What is wrong in my plot

4 visualizzazioni (ultimi 30 giorni)
Aravind Varma
Aravind Varma il 22 Lug 2019
Chiuso: MATLAB Answer Bot il 20 Ago 2021
eh = 8.854e-12;
h = 50e-9;
e0 = (1.465^2)*eh;
e1 = (1.624^2)*eh;
e2 = (1.333^2)*eh;
w1 = 450e-9;
w2 = 750e-9;
for i=1:100
w(i) = w1 + (i-1)/100*(w1-w2);
r01(i) = (sqrt(e0 - e0*0.9806)/e0 - sqrt(e1 - e0*0.9806)/e1)/(sqrt(e0 - e0*0.9806)/e0 + sqrt(e1 - e0*0.9806)/e1);
r12(i) = (sqrt(e1 - e0*0.9806)/e1 - sqrt(e2 - e0*0.9806)/e2)/(sqrt(e1 - e0*0.9806)/e1 + sqrt(e2 - e0*0.9806)/e2);
kz(i) = 2*pi/w(i)*sqrt(e1 - e0*0.9806);
R(i) = (r01(i) + r12(i)*exp(2*1i*kz(i)*h))/(1 + r01(i)*r12(i)*exp(2*1i*kz(i)*h));
end
plot(w,abs(R));

Risposte (1)

Star Strider
Star Strider il 23 Lug 2019
Only ‘w’ and ‘kz’ change (‘r01’ and ‘r12’ calculate the same thing 100 times), and ‘kz’ is multiplied by ‘h’ (which is ) so its influence is negligible, and the plot is essentially a horizontal line.
You can see some variation if you plot the log of ‘|R|’:
plot(w,log(abs(R)))
I have no idea what you are doing, so I cannot suggest any changes, other than to move the ‘r01’ and ‘r12’ calculations before the loop.
  4 Commenti
Aravind Varma
Aravind Varma il 23 Lug 2019
I have another doubt. The plot shows results between 1.5e-7 and 4.5e-7 only whereas I gave the starting and ending points to be 4.5e-7 and 7.5e-7.
Also, I tried using xlim([4.5e-7 7.5e-7]). but it shows nothing in between these limits. (Atleast it should a constant)
Why does this happen?
Star Strider
Star Strider il 23 Lug 2019
‘... I gave the starting and ending points to be 4.5e-7 and 7.5e-7
Well, you actually did not.
If you run:
wlim = [min(w) max(w)]
the result is:
wlim =
1.53e-07 4.5e-07
‘... I tried using xlim([4.5e-7 7.5e-7]). but it shows nothing in between these limits.
That is because there is nothing there to plot.
I have no idea what you are doing, so I cannot offer any suggestions as to how to do what you want. You need to examine your code and figure out the reason it is not doing what you want it to do.

Prodotti


Release

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by