Replace empty element in table located in different rows

3 views (last 30 days)
Song Decn
Song Decn on 26 Oct 2019
Commented: Song Decn on 26 Oct 2019
ann = {'20191025';'20191025';'20190829'};
fann = {'20191025';'20191025';'20190829'};
eann = {'20190930';'20190930';'20190630'};
rec = {877134853.120000;877134853.120000;846524470.030000};
ass = {0;2692456847.78000;2712484638.45000};
cip = {0;88281897.8000000;63035038.2900000};
t = table(ann, fann, eann, rec, ass, cip);
Suppose I have a table like this
t =
3×6 table
ann fann eann rec ass cip
__________ __________ __________ ____________ ____________ ____________
'20191025' '20191025' '20190930' [8.7713e+08] [ 0] [ 0]
'20191025' '20191025' '20190930' [8.7713e+08] [2.6925e+09] [8.8282e+07]
'20190829' '20190829' '20190630' [8.4652e+08] [2.7125e+09] [6.3035e+07]
What I need to get is that if any value of "rec" "ass" "cip" is 0, then it should be replaced with non-zero element of another row with identical "ann" "fann" "eann" properties.
So the results for t would be
ann fann eann rec ass cip
__________ __________ __________ ____________ ____________ ____________
'20191025' '20191025' '20190930' [8.7713e+08] [2.6925e+09] [8.8282e+07]
'20190829' '20190829' '20190630' [8.4652e+08] [2.7125e+09] [6.3035e+07]
Is there a way to achieve this in a fast way?
Thank u very much
  4 Comments
Song Decn
Song Decn on 26 Oct 2019
t2 is how my data are stored, as numeric vectors. Ö

Sign in to comment.

Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!