error horzcat CAT arguments dimensions

1 次查看(过去 30 天)
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
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 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by