2
$\begingroup$

How may I seek help on how to convert a set of 30 cycles encoder data and would like to convert them into a single cycle? Do I have to manually break them down into an individual cycle and then calculate the mean?

Thanks for the help in advance.

Motorencodercycle = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,0., 0., 0., 0., 0., 0., 0.0337956, 0.104719, 0.174556, 0.244632, 0.318658, 0.389918, 0.459921, 0.527533, 0.599649, 0.66759, 0.737422, 0.809181, 0.875762, 0.945095, 1.01589, 1.08755, 1.16111, 1.23334, 1.30497, 1.37637, 1.4464, 1.51948, 1.58933, 1.66407, 1.73348, 1.80597, 1.87667, 1.94798, 2.01754, 2.08859, 2.15752, 2.2292, 2.29793, 2.37053, 2.34346, 2.27264, 2.2028, 2.1296, 2.05725, 1.98476,1.91536, 1.84458, 1.7738, 1.70584, 1.63485, 1.56422, 1.49401, 1.42158, 1.35187, 1.28191, 1.2126, 1.14314, 1.07186, 1.00476, 0.934155, 0.864058, 0.793671, 0.720545, 0.651723, 0.580754, 0.510848, 0.439852, 0.368106, 0.298677, 0.226856, 0.15619, 0.0822221, 0.0130682, 0.0589935, 0.127585, 0.198712, 0.268621, 0.338914, 0.408615, 0.47812, 0.548731, 0.617997, 0.686712, 0.756222, 0.82445, 0.896002, 0.966885, 1.03518, 1.10639, 1.17858, 1.25273, 1.32396, 1.39518, 1.46396, 1.53554, 1.60684, 1.67686, 1.74676, 1.81833, 1.89113, 1.96344, 2.0328, 2.10178, 2.17205, 2.248, 2.32007, 2.38956, 2.32498, 2.25439, 2.18415, 2.11511, 2.04468, 1.97513, 1.90714, 1.83452, 1.76774, 1.69734, 1.6252, 1.55428, 1.48113, 1.41293, 1.34122, 1.27307, 1.19842, 1.12688, 1.05521, 0.984419, 0.915435, 0.841024, 0.76936, 0.698637, 0.624842, 0.552464, 0.483215, 0.413364, 0.342375, 0.272552, 0.204809, 0.134016, 0.0633139, 0.0085117, 0.0786023, 0.146647, 0.221481, 0.291525, 0.363477, 0.433534, 0.504864, 0.575822, 0.647499, 0.719349, 0.789354, 0.862597, 0.933961, 1.00162, 1.07177, 1.14309, 1.21231, 1.28494, 1.35783, 1.43161, 1.50246, 1.57075, 1.64097, 1.71306, 1.78383, 1.85567, 1.92707, 1.99945, 2.06872, 2.14148, 2.21194, 2.28361, 2.35372, 2.35958, 2.28992, 2.21811, 2.14784, 2.07821, 2.00982, 1.93822, 1.86536, 1.79494, 1.72519, 1.65573, 1.58671, 1.51471, 1.44396, 1.37178, 1.30165, 1.23141, 1.15908, 1.08794, 1.01805, 0.948307, 0.876662, 0.807915, 0.738255, 0.66932, 0.599599, 0.529326, 0.461861, 0.391527, 0.320584, 0.25178, 0.182356, 0.114004, 0.0421798, 0.0283042, 0.101733, 0.170768, 0.242098, 0.31199, 0.382333, 0.454231, 0.521456, 0.592329, 0.663679, 0.733894, 0.805752, 0.878528, 0.947604, 1.01774, 1.08854, 1.16342, 1.23425, 1.30406, 1.37229, 1.44461, 1.5118, 1.58417, 1.65206, 1.71866, 1.78926, 1.86113, 1.93085, 2.00296, 2.07276, 2.14623, 2.21679, 2.28727, 2.35772, 2.35912, 2.28773, 2.21586, 2.14346, 2.07222, 1.9993, 1.9279, 1.85642, 1.78287, 1.71339, 1.64363, 1.57479, 1.50645, 1.43823, 1.3687, 1.30081, 1.23066, 1.16025, 1.08915, 1.01962, 0.948296, 0.877084, 0.806402, 0.738199, 0.670428, 0.601908, 0.530493, 0.460037, 0.391753, 0.318954, 0.247765, 0.1761, 0.106757, 0.0372425, 0.0325666, 0.104021, 0.175329, 0.243994, 0.312924, 0.384051, 0.4576, 0.528257, 0.598547, 0.669452, 0.738952, 0.811255, 0.882633, 0.954661, 1.02638, 1.09732, 1.16731, 1.23659, 1.30661, 1.37826, 1.44871, 1.52041, 1.59418, 1.66427, 1.73516, 1.80797, 1.87807, 1.94952, 2.01873, 2.0889, 2.15832, 2.22697, 2.2985, 2.36708, 2.34477, 2.27432, 2.20325, 2.13383, 2.06319, 1.99039, 1.91911, 1.8496, 1.7749, 1.70439, 1.63704, 1.56916, 1.49882, 1.4287, 1.35638, 1.287, 1.21481, 1.14252, 1.07223, 1.00069, 0.926891, 0.854073, 0.784442, 0.711297, 0.641038, 0.568887, 0.49833, 0.430966, 0.360785, 0.29102, 0.221954, 0.152536, 0.0834658, 0.0115883, 0.059732, 0.130192, 0.199177, 0.269212, 0.338935, 0.409787, 0.478198, 0.548971, 0.621314, 0.690732, 0.76261, 0.833474, 0.902546, 0.972208, 1.04477, 1.1179, 1.18667, 1.2583, 1.33091, 1.4007, 1.47069, 1.54314, 1.61489, 1.68773, 1.75774, 1.82761, 1.89766, 1.96769, 2.03859, 2.1071, 2.17651, 2.24266, 2.31527, 2.38333, 2.33264, 2.26066, 2.18759, 2.11896, 2.0481, 1.97683, 1.90525, 1.83594, 1.76698, 1.69554, 1.62411, 1.55361, 1.48362, 1.41379, 1.34338, 1.27042, 1.20258, 1.13601, 1.0651, 0.992938, 0.922422, 0.851814, 0.781536, 0.707696, 0.636817, 0.565563, 0.493732, 0.423529, 0.353791, 0.279725, 0.210597, 0.141111, 0.0716147, 0.00422172, 0.0641341, 0.136777, 0.209647, 0.281262, 0.353264, 0.426202, 0.497058, 0.566917, 0.637366, 0.710709, 0.780127, 0.8488, 0.92105, 0.992043, 1.06108, 1.13186, 1.20411, 1.27619, 1.34783, 1.41893, 1.48996, 1.56081, 1.62996, 1.70215, 1.77416, 1.84398, 1.91562, 1.98703, 2.05589, 2.12885, 2.20022, 2.2691, 2.34203, 2.37156, 2.2996, 2.22654, 2.15649, 2.08679, 2.01316, 1.94129, 1.87148, 1.79902, 1.73101, 1.66094, 1.59236, 1.52124, 1.44997, 1.37822, 1.30924, 1.23888, 1.16613, 1.09556, 1.02265, 0.953898, 0.885341, 0.815445, 0.746865, 0.677543, 0.607868, 0.537442, 0.465531, 0.396328, 0.328445, 0.257319, 0.184482, 0.113958, 0.0412947, 0.030503, 0.102526, 0.174295, 0.247648, 0.319647, 0.392037, 0.461097, 0.53212, 0.60479, 0.67691, 0.746311, 0.814288, 0.883908, 0.957325, 1.02691, 1.09732, 1.17023, 1.24242, 1.31344, 1.38777, 1.46223, 1.53915, 1.61926, 1.69379, 1.76985, 1.84768, 1.93163, 2.00732, 2.08398, 2.15978, 2.2396, 2.31881, 2.38669, 2.30817, 2.23164, 2.15482, 2.06821, 1.98989, 1.91487, 1.83882, 1.76234, 1.68746, 1.61464, 1.5442, 1.47396, 1.40611, 1.33521, 1.26573, 1.19335, 1.12547, 1.05356, 0.982641, 0.913907, 0.844764, 0.767514, 0.698243, 0.629452, 0.556704, 0.487304, 0.417169, 0.347072, 0.275019, 0.202119, 0.131809, 0.0623512, 0.00815642, 0.0788665, 0.149605, 0.218105, 0.290083, 0.359508, 0.432586, 0.502733, 0.572761, 0.640563, 0.710501, 0.779616, 0.848974, 0.919093, 0.990431, 1.05945, 1.12933, 1.20166, 1.27001, 1.33908, 1.40688, 1.47859, 1.54816, 1.61916, 1.69054, 1.7588, 1.83028, 1.8998, 1.97004, 2.03974, 2.10833, 2.1777, 2.24759, 2.31893, 2.38739, 2.32712, 2.25564, 2.18512, 2.11673, 2.04701, 1.97588, 1.90487, 1.83597, 1.76698, 1.69382, 1.62163, 1.55093, 1.47924, 1.41224, 1.34087, 1.26884, 1.19966, 1.12855, 1.05807, 0.986017, 0.914352, 0.842725, 0.773649, 0.701874, 0.629845, 0.563818, 0.493528, 0.423009, 0.354664, 0.284708, 0.213319, 0.143019, 0.0764856, 0.00574005, 0.0662113, 0.138147, 0.206071, 0.278203, 0.3467, 0.415574, 0.487515, 0.558107, 0.629931, 0.702035, 0.774895, 0.84626, 0.918296, 0.991021, 1.06293, 1.1318, 1.20383, 1.27239, 1.34565, 1.41768, 1.49043, 1.55914, 1.63117, 1.69991, 1.77197, 1.84348, 1.91192, 1.98059, 2.05212, 2.12425, 2.19596, 2.26751, 2.33831, 2.37713, 2.30959, 2.24012, 2.16899, 2.09776, 2.02839, 1.9585, 1.88691, 1.81986, 1.7479, 1.67284, 1.60326, 1.53434, 1.464, 1.39412, 1.3201, 1.2506, 1.17961, 1.10816, 1.03529, 0.963884, 0.894621, 0.827003, 0.758105, 0.687892, 0.620122, 0.550367, 0.478906, 0.408054, 0.336591, 0.265978, 0.194885, 0.122649, 0.0535349, 0.0166814, 0.0896184, 0.161053, 0.235222, 0.306813, 0.377852, 0.450035, 0.520598, 0.593604, 0.663542, 0.733679, 0.802044, 0.870685, 0.940842, 1.01045, 1.08008, 1.1526, 1.22349, 1.29254, 1.36044, 1.43222, 1.50251, 1.57092, 1.6427, 1.71327, 1.78344, 1.85555, 1.92957, 1.99871, 2.06931, 2.13897, 2.21032, 2.2796, 2.35051, 2.36234, 2.2923, 2.21986, 2.14765, 2.0779, 2.00756, 1.93573, 1.86514, 1.79539, 1.72423, 1.65631, 1.58723, 1.51601, 1.44514, 1.37546, 1.30516, 1.23723, 1.16931, 1.10026, 1.03081, 0.95723, 0.881917, 0.810691, 0.740045, 0.668695, 0.596028, 0.52455, 0.454314, 0.382638, 0.311036, 0.2407, 0.170454, 0.103188, 0.0318622, 0.0390323, 0.107828, 0.177876, 0.249778, 0.322796, 0.393596, 0.461971, 0.534179, 0.60598, 0.676117, 0.744201, 0.817128, 0.886845, 0.957163, 1.02602, 1.0965, 1.17057, 1.24211, 1.31247, 1.38433, 1.4556, 1.52585, 1.60039, 1.67186, 1.74214, 1.81238, 1.88417, 1.95486, 2.02536, 2.09469, 2.16257, 2.23351, 2.30569, 2.37558, 2.33833, 2.26735, 2.19399, 2.12317, 2.05125, 1.98342, 1.91339, 1.84077, 1.77004, 1.69934, 1.62669, 1.5547, 1.48394, 1.4144, 1.34584, 1.2744, 1.20566, 1.13639, 1.06603, 0.99536, 0.923351, 0.853357, 0.782448, 0.710049, 0.641783, 0.572249, 0.499209, 0.43054, 0.358637, 0.289471, 0.217698, 0.144986, 0.076136, 0.00679588, 0.0623864, 0.133054, 0.203204, 0.27099, 0.338134, 0.407063, 0.476002, 0.547608, 0.617237, 0.686688, 0.757683, 0.826663, 0.896895, 0.968002, 1.03864, 1.10792, 1.17896, 1.24998, 1.31942, 1.38901, 1.45863, 1.52969, 1.59765, 1.66795, 1.74046, 1.80759, 1.87924, 1.9495, 2.01989, 2.09188, 2.16355, 2.23599, 2.30556, 2.37434, 2.33839, 2.26489, 2.1964, 2.12524, 2.05764, 1.98571, 1.9129, 1.83846, 1.7707, 1.69944, 1.62929, 1.55571, 1.48309, 1.41195, 1.34014, 1.26921, 1.1995, 1.12739, 1.05735, 0.984267, 0.913872, 0.843322, 0.772272, 0.699986, 0.631118, 0.560642, 0.48972, 0.420379, 0.352332, 0.27902, 0.204896, 0.136706, 0.0660625, 0.00369704, 0.0719665, 0.144008, 0.215419, 0.284975, 0.355479, 0.42374, 0.495237, 0.564037, 0.636026, 0.707394, 0.776165, 0.845931, 0.918825, 0.988114, 1.05901, 1.13025, 1.20162, 1.273, 1.34534, 1.41446, 1.48748, 1.55982, 1.63196, 1.7044, 1.77497, 1.84567, 1.91579, 1.9881, 2.06022, 2.13225, 2.2039, 2.27232, 2.34228, 2.37366, 2.30524, 2.23333, 2.16319, 2.0917, 2.0216, 1.95047, 1.87934, 1.80829, 1.73441, 1.6622, 1.59179, 1.51939, 1.44809, 1.37958, 1.31013, 1.23684, 1.16837, 1.09602, 1.02448, 0.951367, 0.879741, 0.810806, 0.739413, 0.669519, 0.597465, 0.524833, 0.456677, 0.386109, 0.314871, 0.243298, 0.173593, 0.102778, 0.0307673, 0.0392262, 0.111262, 0.186082, 0.256004, 0.326489, 0.398526, 0.470401, 0.540761, 0.611074, 0.68014, 0.751386, 0.821939, 0.893508, 0.965382, 1.03578, 1.10347, 1.1745, 1.24469, 1.31347, 1.38463, 1.45615, 1.52689, 1.59779, 1.66765, 1.73854, 1.81068, 1.88152, 1.95338, 2.02446, 2.09486, 2.16775, 2.23998, 2.30803, 2.37621, 2.33941, 2.26901, 2.20018, 2.12854, 2.05693, 1.98827, 1.91649, 1.84502, 1.7768, 1.70586, 1.6332, 1.56272, 1.4925, 1.42061, 1.353, 1.28297, 1.21227, 1.14098, 1.07073, 1.00029, 0.930564, 0.857504, 0.785632, 0.715425, 0.644627, 0.574956, 0.506077, 0.435677, 0.36819, 0.296788, 0.22419, 0.156065, 0.0845359, 0.0128276, 0.0575036, 0.127226, 0.19857, 0.268444, 0.340976, 0.412469, 0.484634, 0.554171, 0.624111, 0.694777, 0.768411, 0.837221, 0.909999, 0.980632, 1.04926, 1.11965, 1.18843, 1.25672, 1.32662, 1.39628, 1.46902, 1.54097, 1.61203, 1.68287, 1.75365, 1.82697, 1.89539, 1.96481, 2.03442, 2.10659, 2.17648, 2.24918, 2.32015, 2.39183, 2.32233, 2.2483, 2.17673, 2.10532, 2.03421, 1.9632, 1.8913, 1.82308, 1.75113, 1.68298, 1.61262, 1.54008, 1.46796, 1.3964, 1.32591, 1.25771, 1.18866, 1.11645, 1.04775, 0.976285, 0.905703, 0.836119, 0.762812, 0.691153, 0.618322, 0.544288, 0.47592, 0.405159, 0.332113, 0.262466, 0.194558, 0.122882, 0.0486898, 0.021399, 0.09162, 0.161854, 0.233958, 0.304046, 0.37237, 0.443432, 0.51534, 0.58568, 0.658033, 0.731358, 0.803262, 0.873165, 0.943517, 1.01442, 1.0845, 1.15446, 1.22594, 1.29454, 1.36348, 1.43461, 1.50595, 1.57556, 1.64638, 1.71811, 1.78976, 1.85821, 1.92925, 2.00009, 2.06788, 2.13541, 2.20427, 2.27418, 2.34481, 2.37063, 2.2998, 2.23108, 2.1595, 2.08693, 2.01266, 1.94361, 1.87009, 1.79933, 1.72754, 1.65526, 1.5834, 1.51127, 1.44072, 1.37217, 1.3028, 1.23225, 1.16287, 1.09342, 1.02342, 0.954643, 0.882447, 0.814433, 0.745015, 0.675353, 0.603614, 0.532123, 0.462946, 0.389772, 0.318679, 0.246395, 0.17478, 0.10292, 0.0323977, 0.0387093, 0.108758, 0.18211, 0.256067, 0.327267, 0.400358, 0.469126, 0.541239, 0.61494, 0.684614, 0.753874, 0.824053, 0.894371, 0.967, 1.03688, 1.10721, 1.17843, 1.25189, 1.32156, 1.39277, 1.46392, 1.53274, 1.60176, 1.67262, 1.74296, 1.81383, 1.88562, 1.95728, 2.02769, 2.0968, 2.1694, 2.23875, 2.31023, 2.38066, 2.33536, 2.26349, 2.19084, 2.11926, 2.0474, 1.9769, 1.90539, 1.83212, 1.76333, 1.69079, 1.6213, 1.5494, 1.47911, 1.40812, 1.33729, 1.26575, 1.19584, 1.12601, 1.05639, 0.983911, 0.913369, 0.844473, 0.773936, 0.705209, 0.634624, 0.564634, 0.490127, 0.419008, 0.347892, 0.274637, 0.205369, 0.133318, 0.0639006, 0.00535766, 0.0791982, 0.150212, 0.221932, 0.293569, 0.363593, 0.43634, 0.50883, 0.578362, 0.648962, 0.718744, 0.790883, 0.860245, 0.929929, 1.0009, 1.07237, 1.14248, 1.21116, 1.2818, 1.35364, 1.42481, 1.49406, 1.56523, 1.63659, 1.70628, 1.77563, 1.8474, 1.91947, 1.99176, 2.06259, 2.13453, 2.20514, 2.27206, 2.34025, 2.37591, 2.30485, 2.23509, 2.16357, 2.09312, 2.02333, 1.95117, 1.88345, 1.81226, 1.74194, 1.67282, 1.60262, 1.53088, 1.45816, 1.38581, 1.3142, 1.24398, 1.17316, 1.10399, 1.03165, 0.96226, 0.892789, 0.824514, 0.75449, 0.679097, 0.608955, 0.53937, 0.468488, 0.398959, 0.328228, 0.258568, 0.189394, 0.116667, 0.0473417, 0.0215879, 0.092959, 0.164203, 0.238142, 0.309844, 0.382368, 0.454209, 0.52441, 0.593879, 0.66707, 0.737778, 0.809182, 0.878811, 0.951143, 1.02469, 1.09557, 1.16548, 1.23931, 1.31006, 1.37969, 1.44995, 1.52114, 1.59208, 1.66396, 1.73719, 1.80589, 1.87723, 1.95022, 2.02057, 2.09167, 2.1636, 2.23329, 2.30543, 2.37729, 2.33442, 2.26517, 2.19397, 2.12235, 2.05254, 1.98023, 1.91195, 1.84079, 1.76867, 1.69706, 1.62544, 1.55316, 1.48145, 1.41454, 1.34487, 1.27518, 1.20561, 1.13561, 1.06313, 0.995122, 0.926623, 0.856473, 0.782653, 0.711312, 0.63924, 0.568716, 0.49597, 0.425562, 0.354544, 0.281355, 0.21002, 0.141079, 0.0730673, 0.00317688, 0.0695239, 0.141057, 0.209989, 0.279813, 0.350742, 0.42354, 0.490587, 0.56207, 0.632178, 0.703003, 0.771877, 0.844533, 0.915841, 0.983809, 1.05535, 1.1251, 1.19278, 1.26268, 1.33235, 1.40579, 1.47704, 1.54808, 1.61905, 1.69048, 1.76216, 1.83094, 1.90496, 1.97792, 2.04801, 2.11865, 2.19014, 2.26062, 2.3313, 2.38216, 2.30903, 2.24002, 2.16521, 2.09484, 2.02446, 1.9546, 1.88402, 1.81396, 1.73887, 1.66739, 1.59766, 1.52934, 1.46095, 1.39101, 1.3213, 1.24951, 1.17853, 1.10886, 1.03622, 0.963613, 0.89252, 0.819895, 0.747059, 0.677072, 0.60447, 0.535448, 0.46547, 0.395207, 0.324321, 0.254542, 0.182328, 0.111158, 0.0404288, 0.0306981, 0.101337, 0.173039, 0.24359, 0.312415, 0.384405, 0.455572, 0.528088, 0.598965, 0.668443, 0.742745, 0.810378, 0.883137, 0.955942, 1.02655, 1.09636, 1.16775, 1.23628, 1.30898, 1.37966, 1.45128, 1.52189, 1.59363, 1.66482, 1.73579, 1.80769, 1.87541, 1.94233, 2.0149, 2.08489, 2.15401, 2.22444, 2.29523, 2.3669, 2.34811, 2.2778, 2.20841, 2.13619, 2.06493, 1.99349, 1.92504, 1.85056, 1.77774, 1.70594, 1.63413, 1.56376, 1.49501, 1.42451, 1.35526, 1.2865, 1.21417, 1.14401, 1.07222, 1.00138, 0.93112, 0.860787, 0.789437, 0.718944, 0.649061, 0.582631, 0.516148, 0.445598, 0.374739, 0.303918, 0.23725, 0.165909, 0.0925515, 0.0213945, 0.0518948, 0.121314, 0.191647, 0.26134, 0.332984, 0.403198, 0.47567, 0.54661, 0.618225, 0.687887, 0.757431, 0.829437, 0.900291, 0.971729, 1.04248, 1.11318, 1.18346, 1.25566, 1.32363, 1.39671, 1.46809, 1.5389, 1.60907, 1.68073, 1.75271, 1.82429, 1.89541, 1.96819, 2.03809, 2.10693, 2.17929, 2.24946, 2.31808, 2.38773, 2.32618, 2.25683, 2.18637, 2.11439, 2.04251, 1.97343, 1.90246, 1.83285, 1.764, 1.69189, 1.61955, 1.54875, 1.47715, 1.40997, 1.34285, 1.27107, 1.20167, 1.13216, 1.06232, 0.992389, 0.921218, 0.853121, 0.780321, 0.709327, 0.639291, 0.569246, 0.500774, 0.430166, 0.360336, 0.291496, 0.219471, 0.149546, 0.0785708, 0.0109595, 0.0615326, 0.132746, 0.203888, 0.27627, 0.348079, 0.419523, 0.489112, 0.561471, 0.634013, 0.70362, 0.772562, 0.843149, 0.912883, 0.983378, 1.05438, 1.12485, 1.19607, 1.26809, 1.33987, 1.41096, 1.48322, 1.55431, 1.62275, 1.69629, 1.76842, 1.84003, 1.91181, 1.98447, 2.05449, 2.12461, 2.1941, 2.26731, 2.34156, 2.37269, 2.29987, 2.23091, 2.15921, 2.08903, 2.01688, 1.94276, 1.87239, 1.80099, 1.73423, 1.66496, 1.59337, 1.52063, 1.44767, 1.37544, 1.30392, 1.22837, 1.15776, 1.08581, 1.01429, 0.942522, 0.869443, 0.797399, 0.723619, 0.654288, 0.58432, 0.518023, 0.448535, 0.379496, 0.304882, 0.23205, 0.163049, 0.0906545, 0.0179222, 0.0517203, 0.121879, 0.193869, 0.265893, 0.338677, 0.409424, 0.480199, 0.552645, 0.624149, 0.694789, 0.763974, 0.836692, 0.907951, 0.98049, 1.05204, 1.12058, 1.19599, 1.26756, 1.33939, 1.41117, 1.48015, 1.5493, 1.61858, 1.68683, 1.75817, 1.83063, 1.89956, 1.97293, 2.0418, 2.11294, 2.18326, 2.25362, 2.32424, 2.38955, 2.32127, 2.24789, 2.1782, 2.10604, 2.03461, 1.96035, 1.88968, 1.82276, 1.74956, 1.68059, 1.61018, 1.53756, 1.46321, 1.39329, 1.32286, 1.25253, 1.18079, 1.10941, 1.03795, 0.965949, 0.891758, 0.81841, 0.745121, 0.673508, 0.600745, 0.531582, 0.462173, 0.389662, 0.315992, 0.241805, 0.174209, 0.102613, 0.030634, 0.039632, 0.110035, 0.181249, 0.253677, 0.325271, 0.395962, 0.470064, 0.540084, 0.611565, 0.67961, 0.748333, 0.822598, 0.891827, 0.962778, 1.03255, 1.10602, 1.17622, 1.24679, 1.31931, 1.38739, 1.45607, 1.52749, 1.59719, 1.6682, 1.73619, 1.80455, 1.87667, 1.94584, 2.0152, 2.08532, 2.15471, 2.22495, 2.29422, 2.3687, 2.34728, 2.27609, 2.20301, 2.13536, 2.06638, 1.99522, 1.92533, 1.85422, 1.78632, 1.71596, 1.64523, 1.57406, 1.50366, 1.43209, 1.36122, 1.289, 1.21621, 1.14231, 1.07279, 0.999733, 0.93214, 0.86142, 0.790986, 0.72124, 0.652115, 0.577204, 0.506493, 0.43395, 0.362397, 0.29211, 0.21903, 0.149766, 0.0787296, 0.00799106, 0.063978, 0.132934, 0.202448, 0.269581, 0.338539, 0.409964, 0.480591, 0.548637, 0.620221, 0.693898, 0.764539, 0.833656, 0.905816, 0.978567, 1.04739, 1.11913, 1.1932, 1.26308, 1.33375, 1.40566, 1.47826, 1.5504, 1.61977, 1.68916, 1.75928, 1.82908, 1.90139, 1.97196, 2.04066, 2.10974, 2.1796, 2.25332, 2.32354, 2.38733, 2.31586, 2.24367, 2.17312, 2.09975, 2.02865, 1.95854, 1.88754, 1.81827, 1.74814, 1.67659, 1.60527, 1.53649, 1.46485, 1.39217, 1.32095, 1.25065, 1.17806, 1.10761, 1.03813, 0.970113, 0.901777, 0.832748, 0.762895, 0.693768, 0.623485, 0.552972, 0.481535, 0.410426, 0.34066, 0.270435, 0.200468, 0.129325, 0.059591, 0.0101996, 0.0822541, 0.153521, 0.225267, 0.296882, 0.365527, 0.435217, 0.503848, 0.57333, 0.644789, 0.712294, 0.785158, 0.854296, 0.925793, 0.997408, 1.06878, 1.13576, 1.20636, 1.27844, 1.34914, 1.42197, 1.49185, 1.5613, 1.6359, 1.70599, 1.77682, 1.84732, 1.9198, 1.9894, 2.06196, 2.13428, 2.207, 2.2789, 2.3484, 2.36723, 2.29833, 2.22736, 2.15516, 2.08448, 2.01243, 1.94089, 1.86941, 1.79835, 1.72443, 1.65261, 1.58079, 1.50993, 1.44056, 1.36847, 1.29668, 1.22558, 1.15824, 1.08774, 1.01412, 0.944472, 0.872196, 0.799443, 0.729537, 0.65492, 0.583621, 0.516289, 0.444457, 0.373658, 0.303394, 0.235519, 0.164342, 0.0944481, 0.022383, 0.0469471, 0.114953, 0.184859, 0.254976, 0.324024, 0.39682, 0.468356, 0.536725, 0.606112, 0.674126, 0.741423, 0.811285, 0.883676, 0.954859, 1.02535, 1.09353, 1.16696, 1.23719, 1.30729, 1.37789, 1.44493, 1.5161, 1.59079, 1.66217, 1.73465, 1.80772, 1.8764, 1.94664, 2.01682, 2.08647, 2.15834, 2.22697, 2.29786, 2.36789, 2.3445, 2.27166, 2.20245, 2.13049, 2.05886, 1.98826, 1.92072, 1.8507, 1.78074, 1.71022, 1.63846, 1.56626, 1.49876, 1.42793, 1.35775, 1.28548, 1.21523, 1.14439, 1.07461, 1.00498, 0.932618, 0.860615, 0.788838, 0.718041, 0.648264, 0.578779, 0.504997, 0.434639, 0.362868, 0.289758, 0.219055, 0.149272, 0.080435, 0.00878906}

enter image description here

$\endgroup$

2 Answers 2

3
$\begingroup$

I'm not sure exactly what you want but this might get you started.

First step is to find the main frequency. It has to be around 29 since that's how many peaks I count. But we can also learn that using Fourier, as below. I remove the initial 40 elements since they are not part of the cyclical behavior.

positives = Motorencodercycle[[40 ;;]];
mean = Mean[positives];

ft = Rest@Fourier[positives - mean];
MinMax[Abs[ft]]
{Length[ft], Position[Abs@ft, Max[Abs[ft]]]}

(* Out[245]= {0.000154602, 21.4385}
Out[246]= {1960, {{29}, {1932}}} *)

enter image description here

We can plot this data with x axis folded by the period, as follows.

per = Length[positives]/(29.0);
xvals = Mod[Range[Length@positives], per];
ListPlot[Transpose[{xvals, positives}]]

Using Manipulate as below I can get a slightly better estimate, around 29.025.

Manipulate[per = Length[positives]/(29.0 + e);
 xvals = Mod[Range[Length@positives], per];
 ListPlot[Transpose[{xvals, positives}]], {e, -.1, .2, .001}]
$\endgroup$
3
$\begingroup$

Here is an approach based on a nonlinear regression:

data = Motorencodercycle[[41 ;;]];
nlm = NonlinearModelFit[data, {(2 h/p) Abs[Mod[x - phase, p] - p/2], 
   h > 0 && p > 0}, {{h, 2.75}, {p, 67.5}, {phase, 3 \[Pi]/2}}, x]
nlm["BestFitParameters"]
(* {h -> 2.3903, p -> 67.5603, phase -> 34.516} *)
Show[ListPlot[data, AspectRatio -> 1/3], 
 Plot[nlm[x], {x, 1, Length[data]}]]

Data and fit

Plots of the residuals suggest that there's still some structure yet to be explained above and beyond a symmetric triangular wave. For example the signs of the residuals are opposite for the rising and falling limbs.

f = D[(2 h/p) RealAbs[Mod[x - phase, p] - p/2], x] /. nlm["BestFitParameters"];
slope = f /. x -> # & /@ Range[Length[data]];
rising = Select[Transpose[{slope, Range[Length[data]], nlm["FitResiduals"]}], #[[1]] > 0 &];
falling = Select[Transpose[{slope, Range[Length[data]], nlm["FitResiduals"]}], #[[1]] <= 0 &];
ListPlot[{rising[[All, {2, 3}]], falling[[All, {2, 3}]]}, PlotLegends -> {"Rising limb", "Falling limb"}]

Residuals for rising and falling limbs

Now plot the data with each cycle of data superimposed.

ListPlot[Transpose[{Mod[Range[Length[data]] - phase + p/2, p] /. nlm["BestFitParameters"], data}]]

Cycles overlaid

95% single-prediction intervals can be constructed by changing Abs to RealAbs in the function fit by NonlinearModelFit:

nlm = NonlinearModelFit[data, {(2 h/p) RealAbs[Mod[x - phase, p] - p/2], h > 0 && p > 0},
   {{h, 2.75}, {p, 67.5}, {phase, 3 π/2}}, x];

spb = nlm["SinglePredictionBands"];
Show[ListPlot[Transpose[{1 + Mod[Range[Length[data]] - phase + p/2, p] /. nlm["BestFitParameters"], data}],
  PlotStyle -> PointSize[0.003]],
 Plot[spb, {x, 1, 1 + p /. nlm["BestFitParameters"]}, PlotStyle -> {{Thickness[0.003], Red}}]]

Data and 95% single prediction confidence intervals

And, of course, a single prediction for a value x is found with nlm[x].

Addition: Here is an alternative but equivalent model.

f[x_, a_, p_, θ_] := a + (2 a/π) ArcSin[Sin[2 π x/p + θ]]
data = Select[Motorencodercycle, # > 0 &];
nlm2 = NonlinearModelFit[data, f[x, a, p, θ], {{a, 2.75}, {p, 67.5}, {θ, -33}}, x]
nlm2["BestFitParameters"]
Show[ListPlot[data], Plot[nlm2[x], {x, 1, Length[data]}]]

Data and fit for alternative model

While there might seem to be a slight difference in the two figures of all of the data, the predictions are identical.

$\endgroup$
2
  • $\begingroup$ Gets my upvote, and still waiting...(I knew you would post a better solution than mine, and I am fairly sure another is still out there). I wonder why I bother to answer anything to do with cyclic phenomena, yet I keep doing it. Seems, well, meta. $\endgroup$ Commented Feb 1, 2021 at 14:03
  • 2
    $\begingroup$ @DanielLichtblau As a statistician for whatever it's worth I have difficulty deciding whether to use a "completely data driven" approach or add in a model as I don't have the subject matter knowledge. And if the process is well known, I don't understand why the questions don't include a theoretical model to start with. (Then there's the little details like does the cycle start with an index of 0 or of 1.) I'll add the predicted mean and confidence intervals to my answer a bit later today. $\endgroup$
    – JimB
    Commented Feb 1, 2021 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.