error horzcat CAT arguments dimensions

1 view (last 30 days)
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.

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 14 Nov 2012
Edited: Andrei Bobrov on 14 Nov 2012
peaksK = [distancesK(1); peakssK(:); distancesK(end)];
or
peaksK = [distancesK(1), peakssK(:).', distancesK(end)];
  2 Comments
Jan
Jan on 14 Nov 2012
Or:
peaksK = [distancesK; peakssK; distancesK(end)];
joo
joo on 14 Nov 2012
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)];

Sign in to comment.

More Answers (0)

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!