Hi,now i have a question about cell after using "findpeaks". Its very simple question, i guess. I used "findpeaks" and now i have a cell data like follows.
for k=1:10
B{k}=findpeaks(value(:,k),'NPeaks',6);
end
And now cell{B} is consist with some data like this:
[1, 0.35315, 0.35267, 0.25845, 0.14570, 0.14683] [1, 0.25243, 0.19255, 0.14261] [1, 0.28165, 0.17765, 0.14319, 0.12926] .....
Then i want to convert these data to array(matrix) like follows.
1 1 1
0.35315 0.25243 0.28165
0.35267 0.19255 0.17765
0.25845 0.14261 0.14319
0.14570 0.12926
0.14683
if you some idea to solve this problem, please give me some advice. thanks.

댓글 수: 1

KSSV
KSSV 2017년 9월 25일
YOu can convert cell B to a matrix if every cell has same number of elements, else you cannot convert. Read about cell2mat.

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

 채택된 답변

OCDER
OCDER 2017년 9월 26일

0 개 추천

This is one way to do this, but you have to fill in the unused space with something like NaN.
C{1} = [1, 0.35315, 0.35267, 0.25845, 0.14570, 0.14683];
C{2} = [1, 0.25243, 0.19255, 0.14261];
C{3} = [1, 0.28165, 0.17765, 0.14319, 0.12926];
MaxLen = max(cellfun(@numel, C));
D = cell2mat(cellfun(@(x) [x(:); NaN(MaxLen - numel(x), 1)], C, 'UniformOutput', false));
D =
1.0000 1.0000 1.0000
0.3532 0.2524 0.2817
0.3527 0.1926 0.1777
0.2585 0.1426 0.1432
0.1457 NaN 0.1293
0.1468 NaN NaN

댓글 수: 1

Sayaka Kamata
Sayaka Kamata 2017년 9월 27일
Thanks a lot! The problem was about the replacement of empty number!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 データ型の変換에 대해 자세히 알아보기

질문:

2017년 9월 25일

댓글:

2017년 9월 27일

Community Treasure Hunt

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

Start Hunting!