Generating numbers to replace missing values in a column vector
1 view (last 30 days)
Show older comments
Gadelhag M Omar Mohmed
on 1 Apr 2021
Answered: Walter Roberson
on 1 Apr 2021
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
0 Comments
Accepted Answer
Walter Roberson
on 1 Apr 2021
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')
0 Comments
More Answers (0)
See Also
Categories
Find more on Data Preprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!