I am trying to phase shift sine wave data so that all the minimum peaks are shifted to lie along the x axis. I have been trying with this code but running into an error with "Should be list or number in access or evaluation of 'Matrix' , Matrix/*###*/(sineCol < < Get Values)"
Any help would be appreciated.
// Load data
dt = Current Data Table();
// Specify column with sine wave data
sineCol = dt << Column("PITCH");
// Convert sineCol to matrix
sineMat = Matrix(sineCol << Get Values);
// Calculate the index of the minimum peak
minIndex = Loc Min(sineMat);
// Calculate the number of points to shift the data
shiftPoints = N Rows(sineMat) - minIndex;
// Shift the data
shiftedSineCol = J(N Rows(sineMat), 1, .);
For(i = 1, i <= N Rows(sineMat), i++,
shiftedSineCol[i] = If(i <= shiftPoints,
sineMat[shiftPoints - i + 1],
sineMat[N Rows(sineMat) - i + shiftPoints + 1]
)
);
// Create table of shifted data
newTable = New Table("PITCH Shifted", Add Rows(N Rows(dt)));
newTable["PITCH Shifted"] = shiftedSineCol;
newTable["TIME"] = dt:column("TIME");
// Save table
newTable << Save("PITCH Shifted.jmp");