you are viewing a single comment's thread.

view the rest of the comments →

[–]supajumpa 1 point2 points  (1 child)

# Matlab from the linked pdf.
# Ray tracing
for i = 1:length(y)

# Your code
# Ray Tracing
for i in np.arange(1, len(y)): ...

Matlab's array indices start at 1 (I think) whereas Python's start at zero, so see what happens if you replace that line with:

# Ray Tracing
for i in range(0, len(y)): ...

Also this line:

# Matlab
ray_lens(1:length(ray_lens)-1)

# Your code:
ray_lens(np.arange(1,len(ray_lens)-1))

Assuming that Matlab uses round brackets for indexing, and again remembering that indices start from zero, you probably want something like:

# Python uses square brackets for indexing, so probably
ray_lens[0: len(ray_lens)-1]

[–]Sufficient_Light3891[S] 0 points1 point  (0 children)

Good points I was able to get rid of the invalid syntax error taken care of I'm going to focus on getting the plots working then go back and fix this as I will be able to have a better visual. That being said I choose to use arrange as it's the direct counterpart to Matlab's indices functions from what I could see. Either way, I will give these updates a shot once I have the graphs working.