Extending the vector length

2 ビュー (過去 30 日間)
VG
VG 2021 年 12 月 7 日
回答済み: KSSV 2021 年 12 月 7 日
I have a signal with sampling frequency of 20000 and the total lenght of the signal is 200010. Now I want to take a paticular sample around 181600 and give a new variable but I am encountering an error (Index exceeds array bounds.). I could understand clearly that the orginal lenth is less thamn the new length.
Now how should I add zeros to the orginal vector (ch_x1_interval_1) so that it should extend with zeros to the remaining data to get the new signal.
Below is the code that I used it would be very nice to give comments to the code given below.
ch_x1_interval_1_new =ch_x1_interval_1(181600:181600+20000);
Thank you.
  1 件のコメント
VG
VG 2021 年 12 月 7 日
I tried doing it manually by adding zeros and it worked.But its the hard way to do that.

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

回答 (1 件)

KSSV
KSSV 2021 年 12 月 7 日
Two options.
Option 1:Use interpolation to extend the size.
n = length(ch_x1_interval_1) ;
x = 1:n ;
xi = linspace(1,n,181600) ;
iwant = interp1(x,ch_x1_interval_1,xi) ;
Option 2: Appending zeros
n = length(ch_x1_interval_1) ;
m = 181600 ;
iwant = zeros(1,m) ;
iwant(1:n) = ch_x1_interval_1 ;

カテゴリ

Help Center および File ExchangeTime Series Collections についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by