0

Duplicate:
Element-wise array replication in Matlab

How do I upsample a vector by an integral factor without applying any filtering to the upsampled data?

Basically I e.g. want to upsample a vector three times from

[1 -1 -1 1 1 -1 ]

to:

[1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 -1 -1 -1 ]
Community
  • 1
  • 1
Bjarke Freund-Hansen
  • 28,728
  • 25
  • 92
  • 135
  • Note that in the above example you *are* applying a filter, with coefficients [1 1 1]. To upsample without filtering you would need to insert zeroes between each sample, I.e. 1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 -1 0 0 – Paul R Aug 06 '11 at 17:17
  • @Amro: You are right, the answer to that questions answers my question completely. Mark as duplicate? – Bjarke Freund-Hansen Aug 07 '11 at 18:16

1 Answers1

0

Okay, I just found out myself:

resample(samples, upsample_rate, 1, 0);

The fourth parameter tells resample to use a weighted sum of 0 samples for the filter it applies to the upsampled data. Which effectively nullifies the filter.

Bjarke Freund-Hansen
  • 28,728
  • 25
  • 92
  • 135
  • 1
    it is shifted by 1. The last element is 0 and there are only two 1s at the start. – abcd Aug 06 '11 at 16:41