Help with scilab code for calculating transmission coefficient

Click For Summary
SUMMARY

The forum discussion centers on troubleshooting a Scilab code for calculating the transmission coefficient "T" as a function of the air gap "d" between two higher refractive index materials. The original code produced an incorrect graph, with "T" not decreasing as expected. The solution involved modifying the division operation to element-wise division using the syntax "T = 1 ./(1+0.36 .*(sinh(delta)) .^2)", which corrected the output graph to match the expected results.

PREREQUISITES
  • Familiarity with Scilab programming language
  • Understanding of mathematical functions and graph plotting
  • Knowledge of refractive index concepts
  • Experience with element-wise operations in matrix programming
NEXT STEPS
  • Explore Scilab's element-wise operations and syntax
  • Learn about graph plotting techniques in Scilab
  • Investigate the mathematical principles behind transmission coefficients
  • Review Scilab documentation for advanced functions and troubleshooting
USEFUL FOR

Researchers, physicists, and engineers working with optical materials, as well as Scilab users seeking to improve their coding skills and troubleshoot graphing issues.

Reshma
Messages
749
Reaction score
6
I seem to be getting some arbitrary values from my Scilab code for a function. I have to generate a graph showing the dependence of the transmission on the air gap separating two higher refractive index materials i.e. I want to plot "T" as a function of "d".
T = \frac{1}{1 + \beta \sinh^2 (\delta)}
δ = 2∏d/λ

Code:
d = [0:0.01:1]
delta = 2*%pi*d
T = 1/(1+0.36*(sinh(delta))^2)
plot(d,T)
xtitle("Transmission dependence on d","d","T")

The output graph does not match with what I was expecting. The transmission T should start at 1 and decrease with increasing d. Instead the graph seems reversed. I have attached the output graph file. I plotted the graph with the same formula in excel and it turns out right. Can someone take a look at my code and point out where I am going wrong.

Thanks in advance.
 

Attachments

  • graph.jpg
    graph.jpg
    11.8 KB · Views: 524
Technology news on Phys.org
I don't have Scilab but I think your problem is that T is calculated by matrix division not an element by element division. Other than that it seems like the code should work fine.

Try:
T = 1 ./(1+0.36 .*(sinh(delta)) .^2)
 
Wow, that worked (graph attached). Thanks a lot, Bob!
 

Attachments

  • FTR.jpg
    FTR.jpg
    10.6 KB · Views: 552

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 3 ·
Replies
3
Views
1K
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
862
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
857
  • · Replies 12 ·
Replies
12
Views
3K