MATLAB Answers


How to get the central data of a matrix?

Asked by Jason Jeong on 25 Apr 2017
Latest activity Commented on by Jason Jeong on 25 Apr 2017
The short of it is that I need the middle 1024x1 data points in a 1075x1 set.
Long story, I have a signal (1024x1) that is filtered/convoluted with a lowpass filter that gives me a 1024x1/1075x1 filtered signal. From graphing all three (black-original, blue-convolution, red-filter) it looks like the convolution gives me a 1075x1 signal that is shifted from the original signal by the extra data points from the filtering. The filter function is supposed to give me the same size output as the input but it looks like it's just cutting off the last 51 data points and not really centering it.
My question is how do I cut the first and last 25 data points from the 1075x1 matrix so that when I graph the original signal with the filtered signal, it is centered correctly.


Sign in to comment.


1 Answer

Answer by Joseph Cheng
on 25 Apr 2017
Edited by Joseph Cheng
on 25 Apr 2017
 Accepted Answer

you'd use the parameter 'same' in the convolution function
x = [0 1 2 3 4 5 4 3 2 1 0]
conv(x,[0 1 0],'same')
otherwise if you know the length of the convoluted signal giving 25 extra points you can just delete them by
outputans([1:25 end-24:end])=[];

  1 Comment

Thanks for the help!

Sign in to comment.