MATLAB: How to make smooth the vertcat of more vectors

interpolation

If I try to concatenate and plot all my vectros of different size (each one rapresents a big and small wave) the result is that in the image. What I want is that in the blue circles there is no a discontinuity.

Best Answer

I am not certain what you want, since the posted file is not the same as the posted plot image.
Try this:
y = readmatrix('column.txt');
x = 1:numel(y);
Mxv = find(islocalmax(y, 'MinProminence',10, 'MinSeparation',200)); % Indices Of Maxima
for k = 1:numel(Mxv)-1
[minval(k),idx(k)] = min(y(Mxv(k):Mxv(k+1))); % Select Minimum Between Adjacent Maxima
idx(k) = idx(k) + Mxv(k);
end
figure
plot(x,y)
hold on
plot(x(idx), y(idx), 'vr')
plot(x(Mxv), y(Mxv), '^r')
hold off
grid
txtc = sprintfc('x = %4d\ny = %7.3f\n\\downarrow',[x(idx); y(idx)']');
text(x(idx), y(idx)+1, txtc, 'HorizontalAlignment','center', 'VerticalAlignment','bottom')
legend('Data', 'Desired Minima',' Maxima', 'Location','E')
EDIT — (19 Nov 202 at 13:54)
Added text call and plot image. Code otherwise unchanged.
.