-3

i really dont know how to solve this? can someone help me please?

Find the approximation of greatest common divisor for a set of data (a vector of noninteger numbers). In general, these will not have an exact common divisor. The solution (also a floating point number) should be approximated with certain accuracy. E.g.: x = [3.3308 4.4449 7.7828 12.2273 14.4405 21.1161];

epsilon = 0.01;
d = find_gcd(x,epsilon)
d =
1.1111
% verifying result
x/d
ans =
2.9978 4.0005 7.0046 11.0046 12.9966 19.0047
error = x/d – round(x/d)
error =
-0.0022 0.0005 0.0046 0.0046 -0.0034 0.0047
  • What have you tried so far? You might look at the `gcd` and `rat` functions. – horchler Jan 12 '14 at 20:04
  • yes but gdc works for floating numbers?that was my first thought but i think gcd is only for inter numbers, in this case i cant use in my problem – user3188105 Jan 15 '14 at 00:52
  • Try using `rat` first and then `gcd`. You might also need to round (somehow) `x` to two decimal places based on whatever `epsilon` means. Of course `gcd` only works for integers as floating point values are infinitely divisible. You problem is not well defined or clear. – horchler Jan 15 '14 at 15:42
  • epsilon means the maxim error we can assume. what do u mean by not well defined? what has you not understood ? I need to find a function that gaves me thegreatest divisor od a set of floating points , in the example there are x = [3.3308 4.4449 7.7828 12.2273 14.4405 21.1161] and the result must be a range of +/- epsilon. – user3188105 Jan 15 '14 at 16:24

1 Answers1

1

Maybe using the Euclidan Algorithm as procedure would be correct?

Dedrawde
  • 107
  • 1
  • 10