Hi, everyone!

조회 수: 1 (최근 30일)
Ayisha Nayyar
Ayisha Nayyar 2018년 8월 31일
댓글: Ayisha Nayyar 2018년 8월 31일
I need assistance, actually I have a matrix b=2500x21, which is imaginary part of a FRF signal. I want to find peaks for every column, each column represents accelerometer response at different location of a beam. The following code i have written.
for i=1:21
pks(:,i)=findpeaks(b(:,i))
end
pks(:,i)=pks;
Problem is that, the matrix pks just stores last iteration value. I want that all the peak values after every iteration will be stored in a single matrix.
Can any body having suggestions?
  댓글 수: 8
jonas
jonas 2018년 8월 31일
편집: jonas 2018년 8월 31일
Can you attach the data? No point in guessing. I find it hard to believe no error is returned.
Stephen23
Stephen23 2018년 8월 31일
Ayisha Nayyar's "Answer" moved here and formatted correctly:
Hi jonas, I have attached the file, now follow the code and see the results please.
for i=1:21
pks(:,i)=findpeaks(b(:,i))
end
pks(:,i)=pks;

댓글을 달려면 로그인하십시오.

채택된 답변

jonas
jonas 2018년 8월 31일
편집: jonas 2018년 8월 31일
As expected, your code returned the error
Unable to perform assignment because the size of the left side is 3-by-1 and the size of the right side is 6-by-1.
...because of reasons already listed multiple times in the comments.
You can solve this by storing the data in a cell array.
T=readtable('b.xlsx');
b=table2array(T);
pks=cell(21,1);
for i=1:21
pks{i}=findpeaks(b(:,i))
end
pks =
21×1 cell array
{6×1 double}
{6×1 double}
{6×1 double}
{6×1 double}
{7×1 double}
{6×1 double}
{5×1 double}
{7×1 double}
...
  댓글 수: 3
jonas
jonas 2018년 8월 31일
편집: jonas 2018년 8월 31일
No. You can access the peak values in the first column by:
pks{1}
ans =
1.0e-04 *
0.2180
0.0216
0.0040
0.0008
0.0001
-0.0000
As you can see, there are 6 values. Some peak values have extremely small prominence. You can adjust the 'MinPeakProminence' argument of findpeaks if you wish to exclude those.
Further reading on accessing data in cell arrays ( link ).
Ayisha Nayyar
Ayisha Nayyar 2018년 8월 31일
thanks again

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Operations에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by