Я пытаюсь добавить доверительный интервал к некоторым шумовым кривым, которые я сглаживал заранее. Я использовал метод, предложенный в этом ответе . В моем случае я реализовал это так:
tcd % Cell array contains all the original data for multiple files
tcd_smooth % Cell array contains the smoothed data for multiple files
% Store all time-value pairs smaller than the original data in
% lower_bound_times, lower_bound_values and all values larger than
% the original data in upper_bound_times, upper_bound_values
lower_bound_times = time{i_file}(tcd{i_file} < tcd_smooth{i_file});
upper_bound_times = time{i_file}(tcd{i_file} > tcd_smooth{i_file});
lower_bound_values = tcd{i_file}(tcd{i_file} < tcd_smooth{i_file});
upper_bound_values = tcd{i_file}(tcd{i_file} > tcd_smooth{i_file});
% Flip order of arrays to construct closed area that can be filled
X=[upper_bound_times; fliplr(lower_bound_times)];
Y=[upper_bound_values; fliplr(lower_bound_values)];
fill(X, Y , 1,...
'facecolor',colorOrder(mod(i_file-1,7)+1,:), ...
'edgecolor',colorOrder(mod(i_file-1,7)+1,:), ...
'facealpha', 0.2, ...
'edgealpha', 0.2);
Этот фрагмент выполняется для нескольких файлов, обозначенных индексом i_files
. Уровни достоверности хорошо заполнены, как показано на увеличенном графике одной линии:
![Zoomed in image of line with confidence interval](https://i.stack.imgur.com/QYjCI.png)
Однако по какой-то причине конец всех строк связан с начальным, как показано на следующих двух графиках:
![Full plot](https://i.stack.imgur.com/Ib2XY.png)
А правый конец сюжета выглядит так:
![Right end zoomed in](https://i.stack.imgur.com/BtJnU.png)
Я не могу обернуть руку, как избавиться от этих возвращающихся заполненных областей.