Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

error CAT arguments dimensions are not consistent.

Asked by FIR on 21 Nov 2011
 i have following code
genedata=[1:1:100]
 IDX = kmeans(genedata',20)
 for i = 1:20
   genenum(i) = sum(IDX == i);
 end
genes = cell(20,1);
for K = 1 : 20
  genes{K} = genedata(IDX==K);
end
if i perform 
final=[j genenum genes1]

i get that error

Error using ==> horzcat CAT arguments dimensions are not consistent

where j=[1:20]'

please help

0 Comments

FIR

Products

No products are associated with this question.

2 Answers

Answer by Andrei Bobrov on 21 Nov 2011
Accepted answer
genedata=1:100;
IDX = kmeans(genedata',20);
genenum = cell(20,1);
for i = 1:20
    genenum{i} = sum(IDX == i);
end
genes = cell(20,1);
for K = 1 : 20
    genes{K} = genedata(IDX==K);
end
final=[num2cell((1:20)') genenum genes];

variant 2

genedata=1:100;
IDX = kmeans(genedata,20);
genenum = histc(IDX,1:20);
genes = [(1:20)', genenum, zeros(20,max(genenum))];
for i1 = 1:20
    c = genedata(IDX==i1);
    genes(i1,3 + (0:numel(c)-1)) = c;
end

7 Comments

FIR on 21 Nov 2011

THANKS A LOT ANDREI I AM GREATFUL TO U ....one question my professor asking me is ,why those values are contionous

for ex...1,2,3,4,5,6,7
8,9,10,11,12,13,14

i have atached a pdf ,please see see table7,page num12

http://www.sendspace.com/file/29youd

Jan Simon on 21 Nov 2011

I've found table 7, but I do not see a connection to the question about continuity.

FIR on 21 Nov 2011

ok jan ten can u tell how to form that table 7 plz

Andrei Bobrov
Answer by lama riad on 27 Feb 2012

I have this code n when I'm trying to imshow R1_F2 but i'm getting this error ??? Error using ==> vertcat CAT arguments dimensions are not consistent.

Error in ==> imrotate at 129 rotate = maketform('affine',[ cos(phi) sin(phi) 0; ...

Error in ==> just_4_me at 73 R1 = imrotate(I4, -Theta, 'nearest', 'crop'); ----------------------------------------------------------

here is the code:

 % Load first image (I1)
    I1 = imread('cameraman.jpg');
      [SizeX SizeY]=size(I1);
     % rotate the image 
      deg = 5;
       I2 = imrotate(I1, deg, 'bilinear', 'crop');
    % resize the image(scale)
    cb=imresize(I2,0.7,'bicubic');
    % translate the imaged
     xform = [ 1 0 0;0 1 0;20 20 1 ];
    tform_translate = maketform('affine',xform);
    I4 = imtransform(cb, tform_translate,...
    'XData', [1 (size(cb,2)+xform(3,1))],...
    'YData', [1 (size(cb,1)+xform(3,2))],'FillValues',255);
     % ---------------------------------------------------------------------
    % Convert both to FFT, centering on zero frequency component
    FA = fftshift(fft2(I1));
    FB = fftshift(fft2(I4));
    % ---------------------------------------------------------------------
    % Convolve the magnitude of the FFT with a high pass filter)
    H = hipass_filter(512,512).*FA;  
    H_second = hipass_filter(379,379).*FB; 
    % Transform the high passed FFT phase to Log Polar space
    L1= transformImage(H, SizeX, SizeY, SizeX, SizeY, 'nearest', size(H)/ 2, 'valid');
    L2 = transformImage(H_second, SizeX, SizeY, SizeX, SizeY, 'nearest', size(H_second) / 2, 'valid');
        		
    % Convert log polar magnitude spectrum to FFT
    THETA_F1 = fft2(L1);
    THETA_F2 = fft2(L2);
    % Compute cross power spectrum of F1 and F2
    i=sqrt(-1);
    a1 = angle(THETA_F1);
    a2 = angle(THETA_F2);
    THETA_CROSS = exp(i * (a1 - a2));
    THETA_PHASE = real(ifft2(THETA_CROSS));
   % Find the peak of the phase correlation
    THETA_SORTED = sort(THETA_PHASE(:));  
    SI = length(THETA_SORTED):-1:length(THETA_SORTED);
    [THETA_X, THETA_Y] = find(THETA_PHASE == THETA_SORTED(SI));
     % Compute angle of rotation
    DPP = 360 / size(THETA_PHASE, 2);
    Theta = DPP * (THETA_Y - 1);
        % Rotate image back by theta and theta + 180
    R1 = imrotate(I4, -Theta, 'nearest', 'crop');  
    R2 = imrotate(I4,-(Theta + 180), 'nearest', 'crop');
    % Output (R1, R2)

% Take FFT of R1

    R1_F2 = fftshift(fft2(R1));
     imshow(R1_F2)

1 Comment

Jan Simon on 27 Feb 2012

This question has no connection to the original post. Please open a new thread and delete this _answer_.

lama riad

Contact us