How to use interp1 to stretch out smaller vector to the size of larger vector?

37 ビュー (過去 30 日間)
So I have two vectors, lets call them A and B. A is the smaller vector, and has 1260 columns. B is the larger vector and has 1778 columns. I want to take an average of both these vectors. This is being hard because they are different sizes. Is there a way for me to use interp1 so that I can stretch out the smaller vector to match the size of the larger vector? Any help would be really appreciated!

採用された回答

John D'Errico
John D'Errico 2019 年 9 月 30 日
編集済み: John D'Errico 2019 年 9 月 30 日
Assuming that you intend to create a vector of averages, do this:
Ahat = interp1(1:1260,A,linspace(1,1260,1778));
C = (Ahat + B)/2;
  2 件のコメント
Zuha Yousuf
Zuha Yousuf 2019 年 10 月 2 日
Thank you so much! You have no idea how much this has helped me!
SURESH KUMAR
SURESH KUMAR 2024 年 1 月 19 日
it helped me alot . I wanted to strech the time series data without changing the y axis values and it does perfectly however i had to come up with understading about the duration for which i wanted my expension.. Anyways Thanks
Here is my if anyone needs
powNew=interp1(1:legnth(A),A,linspace(1,legnth(A),legnth(A)+increasementYourValue))

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by