Filling gaps in a vector using a secondary data set
조회 수: 4 (최근 30일)
이전 댓글 표시
Hello,
I have two half-hourly precipitation datasets for 2021 (rain gauge 1 and rain gauge 2).
Rain gauge 1 has NaN values at the start and end of the year. For these two time periods I would like to replace the NaN values with data from the rain gauge 2 dataset.
Is there a good way to do this? Do I need to pull out the values I would like to use from each vector and then join them together into a new vector? This seems clunky?
Thank you!
댓글 수: 0
채택된 답변
Les Beckham
2022년 8월 3일
편집: Les Beckham
2022년 8월 3일
rain1 = [nan nan 1:10 nan nan] % example data
rain2 = [20:34]
idx = isnan(rain1); % find where rain1 has nans
rain1(idx) = rain2(idx) % replace them with data from rain2
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!