How to restrict the domain of dependent variable in ode45

8 views (last 30 days)
Hello every one
I have this equation of ray evolution that I want to solve in matlab using ode45
where dn2 / dx equals to n * (dn / dx) and n is a function of x as n(x). n is the refractive index in Optics and this equation shows how the ray evolves in a medium of height x and range z.
β is a constant and existing, but here is my problem: I do not have the explicit form of n(x), instead, I have a data set of n for x = (0,30). How can I solve this equation using ode45, or any other method compatible for this problem, in a way that the dependent variable x is considered between 0 to 30, because my n varibales are bound only to this interval, so that I would only substitute the n variables and rest assured that x is changing according to n. n is a 1 * 300 matrix by the way
  19 Comments
J. Alex Lee
J. Alex Lee on 3 Aug 2020
You have now flipped x's and z's so many times it's hard to know what's what. It seems Walter's question is the most pertinent.
If you have no reason to believe your solution will be bound to the range (0.1,30), then I would say simply test it a posteriori. Follow James's advice to interpolate, and see if your algorithm fails because you try to evaluate n(z) at some value outside the range.
At least for z>30, I've observed that you can probably safely extrapolate linearly.
If you know the asymptotic form of as , you could piece-wise define n(z) as an interpolant from , analytic form for , and linear from .
If β value is less than the trough-like feature in you will likely have no issues, as this will guarantee your derivative to be positive so that .

Sign in to comment.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!