Vector loading with constraint and saving in vector

1 view (last 30 days)
Hi.
I found, and saved peaks information in vector in the cell 'A' with 'findpeaks' function.
And I could see the saved vector array.
I'd like to collect the peak vectors in the range (1<loc<10).
But with this script, I can only get peak values(pks) in the 'B' cell, not vector([pks, locs]).
How can I save disirable vectors in the cell 'B'?
clc;
clear all;
[numbers,strings,raw]=xlsread('C:\Users\marett\Desktop\0310 FFT');
[row, col]=size(numbers);
numArrays = row-2;
A=cell(numArrays,2);
B=cell(numArrays,2);
x=numbers(:,2);
for n=1:col
y=numbers(:,n+2);
ys=smooth(y,50,'sgolay',5);
[pks,locs] = findpeaks(ys,x,'MinPeakDistance',0.5);
A{n}=[pks,locs];
B{n}=A{n}(locs>1&locs<10);
end

Accepted Answer

Chunru
Chunru on 31 Aug 2021
clc;
clear all;
[numbers,strings,raw]=xlsread('C:\Users\marett\Desktop\0310 FFT');
[row, col]=size(numbers);
numArrays = row-2;
A=cell(numArrays,2);
B=cell(numArrays,2);
x=numbers(:,2);
for n=1:col
y=numbers(:,n+2);
ys=smooth(y,50,'sgolay',5);
[pks,locs] = findpeaks(ys,x,'MinPeakDistance',0.5);
A{n}=[pks,locs];
B{n}=A{n}(locs>1&locs<10, :); % Add ", :" here
end

More Answers (0)

Tags

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!