From: Mahadev Ittina Date: 2009-11-23T05:44:54+09:00 Subject: Re: Finding the closest value from a matrix thanks for all the methods. I never realised there were so many ways to do it! I decided to do the 1st method. I have repeat the method a couple of more times than shown here.. Its a good way. reinforcement = [6, 8, 10, 12, 16, 20, 25, 32, 40] number = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] diameters = [8, 10, 12, 16] spacings = [85, 90, 100, 125, 150, 175, 200, 225, 250, 275, 300] @shear_links = diameters.product(spacings).map { |d, s| [0.5 * Math::PI * d ** 2 / s, d, s] }.sort.find { |x,| x > @asw_s } @compression = reinforcement.product(number).map { |r, n| [0.25 * Math::PI * r ** 2 * n, r, n] }.sort.find { |x,|x > @comp_steel} @tension = reinforcement.product(number).map { |r, n| [0.25 * Math::PI * r ** 2 * n, r, n] }.sort.find { |x,|x > @ten_steel} -- Posted via http://www.ruby-forum.com/.