3 views (last 30 days)

Star Strider
on 19 Nov 2020

Edited: Star Strider
on 19 Nov 2020

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.

.

Star Strider
on 19 Nov 2020

Filter it:

y = load('columntrue.txt');

x = 1:numel(y);

Fs = 1;

Fn = Fs/2;

L = numel(y);

FTy = fft(y)/L;

Fv = linspace(0, 1, fix(L/2)+1)*Fn;

Iv = 1:numel(Fv);

figure

plot(Fv, abs(FTy(Iv))*2)

grid

xlim([0 0.1])

yfilt = lowpass(y, 0.005, Fs);

figure

subplot(2,1,1)

plot(x, y)

title('Original Signal')

grid

subplot(2,1,2)

plot(x, yfilt, '-r')

title('Lowpass-Filtered Signal')

grid

producing:

.

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

Start Hunting!
## 7 Comments

## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/653248-how-to-make-smooth-the-vertcat-of-more-vectors#comment_1145773

⋮## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/653248-how-to-make-smooth-the-vertcat-of-more-vectors#comment_1145773

## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/653248-how-to-make-smooth-the-vertcat-of-more-vectors#comment_1145818

⋮## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/653248-how-to-make-smooth-the-vertcat-of-more-vectors#comment_1145818

## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/653248-how-to-make-smooth-the-vertcat-of-more-vectors#comment_1146148

⋮## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/653248-how-to-make-smooth-the-vertcat-of-more-vectors#comment_1146148

## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/653248-how-to-make-smooth-the-vertcat-of-more-vectors#comment_1146158

⋮## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/653248-how-to-make-smooth-the-vertcat-of-more-vectors#comment_1146158

## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/653248-how-to-make-smooth-the-vertcat-of-more-vectors#comment_1146213

⋮## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/653248-how-to-make-smooth-the-vertcat-of-more-vectors#comment_1146213

## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/653248-how-to-make-smooth-the-vertcat-of-more-vectors#comment_1146498

⋮## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/653248-how-to-make-smooth-the-vertcat-of-more-vectors#comment_1146498

## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/653248-how-to-make-smooth-the-vertcat-of-more-vectors#comment_1146798

⋮## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/653248-how-to-make-smooth-the-vertcat-of-more-vectors#comment_1146798

Sign in to comment.