Obtaining variables from a list of values depending on user input
1 次查看(过去 30 天)
显示 更早的评论
Hello everybody: I am writing to ask for desperate help. I want to create a function which calculates the refractive index of silicon. As I haven't been able to find any formulas for this, I have instead found a list with different values of refractive index at different wavelengths in the form of a .txt file like shown below (extract):
Wavelength(nm)-refractive index-extinction coefficient
190.7 -0.847- 2.73
198.4 -0.968- 2.89
206.6 -1.11- 3.05
207.3 -1.036- 2.928
208 -1.046- 2.944
208.7 -1.066- 2.937
209.4 -1.07- 2.963
The idea is, that the user will insert a certain wavelength, and from that wavelength, the function will calculate the refractive index by looking into the list (the text file)and probably using the closest to the value inserted by the user, assigning then the correct value to the refractive index of Silicon.
SO; to make it simple: A function that when given a certain wavelength (input by the user) will look up the corresponding refractive index in the list assigning that value to a variable I will call nSi.
Is there any chance of someone telling me how to do this? Is there maybe a simpler way? Thanks everyone very much as I am doing a PhD and it is my first time programming with Matlab and I'm learning by myself...
0 个评论
采纳的回答
Andreas Goser
2012-1-26
This looks like a good use for Interpolation with the INTERP1 command. There are however multiple way to interpolate, fit, etc. Give it a try and if you run into problems, Post code and data.
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!