Generating numbers to replace missing values in a column vector

3 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Random Number Generation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by