Can anyone identify this finite difference approximation code?

11 views (last 30 days)
The code is as follows:
if bool == 1,
h = 2/n;
RT = ([RT(end,:); RT(1:end-1,:)] + [RT(2:end,:); RT(1,:)] - 2*RT)/h^2;
end
where RT is an image (a sinogram for back-projecting in this case) and n is the size of the image to be reconstructed. I need to able to identify which kind of finite difference it is and to what accuracy. I then need to produce code to do the same thing for the first derivative of the same accuracy. If anyone could identify this and perhaps help with the code too that would be great.
Thanks, Josh
  2 Comments
Walter Roberson
Walter Roberson on 5 Jul 2017
That appears to be like f(x(n-1)) + f(x(n+1)) - 2 * f(x(n)) / delta^2, except with a circular wrap around. At the moment I do not catch why h is being squared.
My thought is that it looks to me to be more like a smoothing method than a finite difference approximation. However, I have little experience with finite difference approximation.
Joshua Cronin
Joshua Cronin on 6 Jul 2017
Do you not normally divide by the spacing to the power of the derivative when implementing the finite difference approximation? I'm thinking it could be finite forward difference with the 1st level of accuracy. Thanks for the help

Sign in to comment.

Answers (1)

Joshua Cronin
Joshua Cronin on 6 Jul 2017
I believe I have figured it out. The code above is the central finite difference of the second derivative, used to an accuracy of 2, with a circular wrap around to keep the dimensions constant. Applying the central finite difference in the same way for the first derivative will look like:
RT = (-0.5*[RT(end,:); RT(1:end-1,:)] + 0.5*[RT(2:end,:); RT(1,:)])/h;

Categories

Find more on Biomedical Imaging in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!