Translated to C# version of Rasmus Farm control (matlab)

not tested, not run