I want to save [pks,locs] data for every iteration
3 views (last 30 days)
Show older comments
order = 3;
framelen = 3001;
% Savitzky-Golay condition %
A = zeros(120001,size(force,2));
for i=1:size(force,2);
LF = force(:,i);
sgf = sgolayfilt(force(:,i),order,framelen);
[pks,locs] = findpeaks(sgf,'minpeakdistance',2000,'minpeakheight',2.0,'minpeakprominence',0.05);
% Finding peak point condition %
A(:,i)=sgf;
B=[pks,locs]
writematrix(A,'D:\1. GS\data\15mm.xlsx','sheet',1);
writematrix(B,'D:\1. GS\data\15mm.xlsx','sheet',2,'Range','B1:Z100');
subplot(size(force,2),1,i);
text(locs+1000.0,pks+0.2,num2str((1:numel(pks))'));
----------------------------------------------------------------------------------------------------------
This is my code.
I want to save the pks & locs data for every iteration in for loop.
I tried to store the data about the B matrix in each column like the A matrix, but finally failed. Because the number of pks and locs data obtained for each iteration changed, the size of the matrix could not be determined and the data could not be stored in the same way.
I would appreciate it if you could help me with the solution in this case.
0 Comments
Accepted Answer
Star Strider
on 9 Jan 2023
Since the ‘[pks,locs]’ data may not be the same in every iteration, save them to cell arrays —
[pks,locs] = findpeaks(sgf,'minpeakdistance',2000,'minpeakheight',2.0,'minpeakprominence',0.05);
pksc{i} = pks;
locsc{1} = locs;
You can slso save them as an array —
[pks,locs] = findpeaks(sgf,'minpeakdistance',2000,'minpeakheight',2.0,'minpeakprominence',0.05);
pkslocs{i} = [pks locs];
.
4 Comments
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!