error horzcat CAT arguments dimensions

does anyone understand why am i getting this error:
??? Error using ==> horzcat CAT arguments dimensions are not consistent. Error in ==> code at 60 peaksK = [distancesK(1), peakssK, distancesK(end)];
when using this code:
(distancesK = 582x1 double)
[peakssK, iPeakssK] = findpeaks(distancesK);
peaksK = [distancesK(1), peakssK, distancesK(end)];
i have already used this code million times but now it is giving me this error. can anyone help me please? thank you very much.

 採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 11 月 14 日
編集済み: Andrei Bobrov 2012 年 11 月 14 日

0 投票

peaksK = [distancesK(1); peakssK(:); distancesK(end)];
or
peaksK = [distancesK(1), peakssK(:).', distancesK(end)];

2 件のコメント

Jan
Jan 2012 年 11 月 14 日
Or:
peaksK = [distancesK; peakssK; distancesK(end)];
joo
joo 2012 年 11 月 14 日
thank you so much for the both of you.it worked like this. thank you.
peaksK = [distancesK(1), peakssK.', distancesK(end)];
iPeaksK = [1, iPeakssK.', length(distancesK)];

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLanguage Fundamentals についてさらに検索

質問済み:

joo
2012 年 11 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by