Infil NaN for missing years in time series
Show older comments
Hello:
I have two matrices, A and B. Matrix B has some years missing in it. I want to concatenate horizontally two matrices, A and B to a new matrix C, which can be filled with NaN for the missing years.
A =
1981 0.79 1.56 0.90 1.15
1982 0.62 0.83 0.84 0.74
1983 0.81 0.71 0.71 0.70
1984 1.06 0.74 0.61 0.76
1985 1.23 0.86 0.67 0.61
1986 1.32 0.56 1.11 0.76
1987 0.75 1.06 0.56 1.15
1988 1.76 1.09 0.88 0.67
1989 0.90 0.77 0.94 0.77
1990 0.52 0.52 1.15 0.88
and B =
1981 1.0617
1982 1.0682
1985 1.0149
1986 0.6607
1987 0.5642
1988 0.6194
1989 0.6693
1990 0.6966
Desired output, C =
1981 1.0617 0.79 1.56 0.90 1.15
1982 1.0682 0.62 0.83 0.84 0.74
1983 NaN 0.81 0.71 0.71 0.70
1984 NaN 1.06 0.74 0.61 0.76
1985 1.0149 1.23 0.86 0.67 0.61
1986 0.6607 1.32 0.56 1.11 0.76
1987 0.5642 0.75 1.06 0.56 1.15
1988 0.6194 1.76 1.09 0.88 0.67
1989 0.6693 0.90 0.77 0.94 0.77
1990 0.6966 0.52 0.52 1.15 0.88
Accepted Answer
More Answers (0)
Categories
Find more on Logical 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!