Borrar filtros
Borrar filtros

Generating numbers to replace missing values in a column vector

3 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Walter Roberson
Walter Roberson el 1 de Abr. de 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')
B = 60×1
0.5800 0.7000 0.8200 0.9400 1.0600 1.3420 1.6240 1.9060 2.1880 2.4700

Más respuestas (0)

Categorías

Más información sobre Random Number Generation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by