# MATLAB: Error using ==> horzcat CAT arguments dimensions are not consistent.

feature vectorhorizontal concatenationMATLAB

I want to find feature vectors.. for that i executed the following code
clear all; close all; clc;im1=imread('lena.jpg'); im1g=rgb2gray(im1); %%Calculating mean of im1 grayImage=rgb2gray(im1);subplot(1, 2, 1); imshow(grayImage, []); title('Original Grayscale Image'); % Let's get its histogram. [pixelCount grayLevels] = imhist(grayImage); subplot(1, 2, 2); bar(pixelCount); title('Histogram of original image'); xlim([0 grayLevels(end)]); % Scale x axis manually. yRange = ylim; % Calculate the mean gray level meanGL = sum(pixelCount .* grayLevels) / sum(pixelCount);%%Calculating standard deviationst_d1=std(double(im1));%%Calculating Skewnesssk1=skewness(double(im1));%%Calculating RMSim1=double(im1);rms1=rms(im1); %%Calculating median absolutemd1=mad(double(im1));%%Contruct a feature vectorsize(meanGL2)size(st_d2)size(sk2)size(rms2)size(md2)fv1=[ meanGL,  st_d1, sk1, rms1, md1];
and i get that concatenation error .. the size of the variables displayed in the output screen are
ans =       1     1ans =       1   512     3ans =       1   512     3ans =       1   512     3ans =       1   512     3??? Error using ==> horzcatCAT arguments dimensions are not consistent.Error in ==> fvector at 64fv1=[ meanGL,  st_d1, sk1, rms1, md1];
i am new to matlab and so dont know how to fix it.. if possible any solutions..

• Since you say you're trying to construct a feature vector from the expression
fv1=[ meanGL,  st_d1, sk1, rms1, md1];
but of the five only the first,
meanGL = sum(pixelCount .* grayLevels) / sum(pixelCount);
isn't a higher dimension than single, I presume what you intended to write for
%%Calculating standard deviationst_d1=std(double(im1));
and the remaining would have been
    st_d1=std(im1(:));
which will return the std dev of the entire image array im1 whereas the default behavior of std in Matlab is to operate on the planes hence return the 1x512x3 size. See
doc std
for further description/details. The (:) notation casts the array into a vector so the operation is then done on that one column and the result is then the desired single value for the entire image.
Same logic/fix for the rest.