Interpolate big array to match length of smaller array?

18 ビュー (過去 30 日間)
Marissa Menzel
Marissa Menzel 2018 年 9 月 25 日
編集済み: jonas 2018 年 9 月 25 日
I am trying to do some array math, but my arrays are different sizes. I tried to interpolate the larger array, tau, (13795 x 1) to match the length of the smaller one, rho, (105 x 1). Neither data set is linear. I tried to do 1D interpolation with interp1(...) function but got the following error: "error using GriddedInterpolant The grid vectors do not define a grid of points that match the given values"
My end goal is to get the longer tau array to be (105 x 1).
  6 件のコメント
Marissa Menzel
Marissa Menzel 2018 年 9 月 25 日
They are density (rho) and wind stress (tau) that I am reading in from a data table file.
jonas
jonas 2018 年 9 月 25 日
Measured over what? Over time? Over a geometry? Why are they different size?

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

回答 (1 件)

jonas
jonas 2018 年 9 月 25 日
編集済み: jonas 2018 年 9 月 25 日
You need an x vector for interp.
tau_new=interp1(X_tau,tau, X_rho)
tau_new is the interpolated vector
  2 件のコメント
Marissa Menzel
Marissa Menzel 2018 年 9 月 25 日
I don't have an xshort and I can't just make one with linspace because it is non linear.
jonas
jonas 2018 年 9 月 25 日
編集済み: jonas 2018 年 9 月 25 日
Can you upload and describe the data? You said you got the data from a table. What does the row number of the table represent? Is there a time associated with the values or perhaps a geometry? rho and tau must surely be functions of something right? Unless of course they are repeated measurements to get a measure of their distributions. In this case it is however senseless to interpolate.
Anyway, I am not supposed to figure it out.

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

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by