Help with scilab code for calculating transmission coefficient

AI Thread Summary
The discussion revolves around a Scilab code issue where the user is attempting to plot the transmission (T) as a function of the air gap (d) between two materials with higher refractive indices. The formula used for T is T = 1/(1 + β sinh²(δ)), where δ is defined as δ = 2πd/λ. The user reports that the output graph does not align with expectations, as T should start at 1 and decrease with increasing d, but the graph appears reversed. A contributor suggests that the problem lies in the way T is calculated, specifically that matrix division is being used instead of element-wise division. They recommend modifying the code to use element-wise operations, which resolves the issue and produces the expected graph. The user confirms that this adjustment worked and thanks the contributor for the assistance.
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: 517
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: 545
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Back
Top