フィルターのクリア

inserting values in between two successive values in an array

1 回表示 (過去 30 日間)
Mohammed Yousuf
Mohammed Yousuf 2021 年 5 月 25 日
コメント済み: Mohammed Yousuf 2021 年 5 月 25 日
I have an array 10X1
-7.55
-7.62
-7.59
-7.75
-7.78
-7.69
-7.63
-7.69
-7.58
-7.95
Now, i want to insert values in between two successive values as (-7.585) in between ( -7.55 -7.62) and so on, so that my array become 19X1.

採用された回答

Rik
Rik 2021 年 5 月 25 日
This should get the job done:
data=[-7.55;-7.62;-7.59;-7.75;-7.78;-7.69;-7.63;-7.69;-7.58;-7.95];
newdata=interp1(...
1:numel(data),... create x values
data,... treat the data as y values
1:0.5:numel(data),... create the new x values to sample
'linear'); % force the use of a linear interpolation
disp(newdata)
-7.5500 -7.5850 -7.6200 -7.6050 -7.5900 -7.6700 -7.7500 -7.7650 -7.7800 -7.7350 -7.6900 -7.6600 -7.6300 -7.6600 -7.6900 -7.6350 -7.5800 -7.7650 -7.9500
  3 件のコメント
Rik
Rik 2021 年 5 月 25 日
What exactly do you mean by 'after the 10th value'? Do you want to extrapolate after the array you have? If you want that, you will have to find the pattern in your numbers.
plot(data)
I don't see any pattern. Can you predict what value should be at x=10.5?
Mohammed Yousuf
Mohammed Yousuf 2021 年 5 月 25 日
oK. I understood, thanks for your answer.

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

その他の回答 (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