Resampling vector from the middle sample (Keeping the symmetry)
1 view (last 30 days)
Show older comments
Hi All,
I would like to re-sample a vector using different sample rates. But I would want to keep the symmetry as it is.
E.g. h = [ 0.1 0.3 0.7 0.3 0.1]; % Original vector with 5 samples h2 = resample(h,4,5); % Re-sampled vector into 4 samples
But the above command doesn't give a symmetric vector as the original one. Is there any way to re-sample keeping the symmetry around the center sample ?
Thanks very much.
2 Comments
Dishant Arora
on 20 Jun 2014
And how would you define a centre element in case of even length sampled array?
Answers (1)
Image Analyst
on 23 Jun 2014
Try interp1(), or if you have the Image Processing Toolbox, imresize():
% Method using interp1()
h = [ 0.1 0.3 0.7 0.3 0.1]
x = 1 : length(h);
newNumberOfSamples = 4;
xq = linspace(x(1), x(end), newNumberOfSamples);
h2 = interp1(x, h, xq)
% Method using imresize (slightly different)
h3 = imresize(h, [1, newNumberOfSamples])
In the command window:
h =
0.1 0.3 0.7 0.3 0.1
h2 =
0.1 0.43333 0.43333 0.1
h3 =
0.11644 0.48579 0.48579 0.11644
The numbers are somewhat different because where each puts the "end point" x values is different. Interp1, the way I did it, pins down the first and last x value while imresize picked the "in between" x values (1.5, 2.5, 3.5, 4.5)
Use whichever method you want.
0 Comments
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!