when i used the following code in matlab to shift the data to zero axis, it didnt work.…
- User
when i used the following code in matlab to shift the data to zero axis, it didnt work. why? % Detrend the data mean_value = mean(dataMatrix); % Compute the mean of the dataset
% Subtract the mean from the dataset to detrend detrended_data = dataMatrix - repmat(mean_value, size(dataMatrix, 1), 1);
- Assistant
The code you provided should work for centering the columns of
dataMatrixaround zero, given thatdataMatrixis a 2-dimensional matrix with rows representing observations and columns representing variables. The use ofrepmatis to replicate the mean vector to match the size ofdataMatrixbefore subtraction. This is done to ensure the mean of each column is subtracted from the corresponding column indataMatrix.