Shorten vectors keeping the same range

Hello,
I'm trying to shorten a vector to create a data comparison. I have a vector that has 1004 values (which are positions within 15 seconds) and another that has 5034 in the same 15 seconds. Is there a way to shorten the vector from 5034 to 1004 values and still keep s 15 seconds?
Thanks in advance
MSP

4 件のコメント

dpb
dpb 2019 年 8 月 2 日
Is there an associated timestamp or are the data just sampled at either a fixed rate or just scan frequency?
There are any number of ways to choose, the simplest is to just pick the closest integer in the 1:NLonger range mapped to 1:NShorter...you could also average or interpolate or do most anything depending upon what you actually want to select.
Or, if have Signal Processing TB, there's resample() that has several options from which to choose.
MSP
MSP 2019 年 8 月 2 日
編集済み: MSP 2019 年 8 月 2 日
Thanks for the quick response.
Unfortunately the samples do not have exactly the same time scale. The sampling time is different. It would be even better if there was some way to make the scales turn the same. Do you have any idea how could I do it?
the cyclist
the cyclist 2019 年 8 月 2 日
Uploading your data (or a representative sample) in a MAT file would be helpful.
dpb
dpb 2019 年 8 月 2 日
Again, the missing information is whether there is a timestamp associated or what the sampling paradigm was.
resample does just that with the assumption of a fixed sample rate for each by one of several methods; or, you can use it to resample via interpolation at an arbitrary set of points.
If you have a time that can be associated, you could use the timeseries object which has its internal resample method or there is synchronize to pair up two or more...
Again, there are more ways to do this than can shake a stick at...start exploring the documentation...

サインインしてコメントする。

回答 (1 件)

Athul Prakash
Athul Prakash 2019 年 8 月 5 日
編集済み: Athul Prakash 2019 年 8 月 5 日

0 投票

Hey martin,
There are multiple methods you should consider:
I assume you're trying to downsample a signal.
If that is the case, consider the "resample" funciton (documentation linked below).
Alternatively, you may use the "interp1" function (documentation linked below) to perform a simple interpolation on your 5034x1 vector and get a 1004x1 vector output.
If your vector represents some sort of signal value over time, resample is recommended over interp1.
Again, there are multiple ways to do this, depending on your requirement.
Good Luck.

カテゴリ

製品

リリース

R2017a

質問済み:

MSP
2019 年 8 月 2 日

編集済み:

2019 年 8 月 5 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by