フィルターのクリア

Generating numbers to replace missing values in a column vector

3 ビュー (過去 30 日間)
Gadelhag M Omar Mohmed
Gadelhag M Omar Mohmed 2021 年 4 月 1 日
回答済み: Walter Roberson 2021 年 4 月 1 日
Hi
I have a column vector has 60 values placing in order from small to large numbers, however some of these values are missing (has Zero values) I want to generate some values to replace these zeros in the missing cells within the order of the other numbers (non missing numbers) in the vector.
For example:
my vector is A:
A= [0.58; 0; 0; 0; 1.06; 0; 0; 0; 0; 2.47; 0;
0; 0; 0; 5.16; 0; 0; 0; 0; 10.94; 0; 0; 0; 0; 22.25;
0; 0; 0; 0; 42.82; 0; 0; 0; 0; 66.60; 0; 0; 0; 0; 93.45;
0; 0; 0; 0; 119.43; 0; 0; 0; 0; 183.43; 0; 0; 0; 0; 248.94;
0; 0; 0; 0; 320.76];
So, the values to be generated for repalcing the zeros in cells A(1, 2:4) should be in order between the valuse 0.58 and 1.06, and the same for the other zeros.
Hopefully I have explained the question in a clear way, and thanks in advance for helping me.
Regards

採用された回答

Walter Roberson
Walter Roberson 2021 年 4 月 1 日
A= [0.58; 0; 0; 0; 1.06; 0; 0; 0; 0; 2.47; 0;
0; 0; 0; 5.16; 0; 0; 0; 0; 10.94; 0; 0; 0; 0; 22.25;
0; 0; 0; 0; 42.82; 0; 0; 0; 0; 66.60; 0; 0; 0; 0; 93.45;
0; 0; 0; 0; 119.43; 0; 0; 0; 0; 183.43; 0; 0; 0; 0; 248.94;
0; 0; 0; 0; 320.76];
B = fillmissing(standardizeMissing(A, 0),'linear')
B = 60×1
0.5800 0.7000 0.8200 0.9400 1.0600 1.3420 1.6240 1.9060 2.1880 2.4700

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by