MATLAB: Horzcat CAT arguments dimensions are not consistent.

horzcat cat arguments dimensions are not consistent.

I have problem with my code.
??? Error using ==> horzcat CAT arguments dimensions are not consistent.
Error in ==> rozpoznawanie_dzwiekowPerc at 209 mfcc_kaszel = [mfcc_kaszel; [c sp_bw sp_centroid sp_rolloff shortte zerocr]];

Best Answer

  • I'm not sure if you want an 82 row by 18 column array as the output, or a 18 row by 82 column array, so here is how to do it both ways:
    % Define sample data for testing.
    mfcc_kaszel = [];
    c = ones(82,13);
    shortte = ones( 82,1);
    sp_bw = ones( 1,82);
    sp_centroid = ones(1,82);
    sp_rolloff = ones( 1,82);
    zerocr = ones(82,1);
    % Make 82 row by 18 column matrix.
    mfcc_kaszel = [mfcc_kaszel; [c, sp_bw', sp_centroid', sp_rolloff', shortte, zerocr]];
    % Make 18 row by 82 column matrix.
    mfcc_kaszel2 = [c'; sp_bw; sp_centroid; sp_rolloff; shortte'; zerocr'];