sum up pixels by using simple continued fraction

When i read an image, there are pixels show in workspace. I need to sum up the first row of pixels by using simple continued fraction. I wish to add those pixels by looping, but i don't know how to assign the position of pixels into loop.
For example, this is the pixels for the first row of image:
[255;255;255;241;220;211;211;221;244;255;255;255]
Now I find the simple continued fraction by using this method:
A = Z(1)+1/(Z(2)+1/(Z(3)+1/(Z(4)+1/(Z(5)+1/(Z(6)+1/(Z(7)+1/(Z(8)+1/(Z(9)+1/(Z(10)+1/(Z(11)+1/Z(12)))))))))));
Can simple continued fraction perform by using looping? Thank you.

Answers (1)

Your question is confusing since you're talking about rows yet you show a column vector in your example.
To compute the continuous fraction of all the rows at once:
A = Inf;
for column = fliplr(double(Z)) %conversion to double just in case Z is uint8
A = 1./A + column;
end

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 4 May 2017

Edited:

on 4 May 2017

Community Treasure Hunt

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

Start Hunting!