MATLAB: Please help me in this code how to over come from this error i will be posting the code

horzcat

clear;clc;
One= [-1 1 -1 -1 -1, -1 1 -1 -1 -1,-1 1 -1 -1 -1,-1 1 -1 -1 -1,-1 1 -1 -1 -1,-1 1 -1 -1 -1,-1 1 -1 -1 -1,];
Two= [-1 -1 1 -1 -1, -1 1 -1 1 -1, 1 -1 -1 -1 1, -1 -1 -1 1 -1, -1 -1 1 -1 -1, -1 1 -1 -1 -1,1 1 1 1 1];
Three=[-1 1 1 1 -1,-1 -1 -1 1 -1, -1 -1 -1 1 -1, -1 -1 1 1 -1, -1 -1 -1 1 -1, -1 -1 -1 1 -1, -1 1 1 1 -1];
Four= [1 -1 -1 -1 -1,1 -1 -1 -1 -1,1 -1 -1 -1 -1,1 -1 1 -1 -1, 1 1 1 1 1, 1 1 1 1 1, -1 -1 1 -1 -1];
Five= [-1 1 1 1 1, -1 1 -1 -1 -1, -1 1 -1 -1 -1, -1 1 1 1 1, -1 -1 -1 -1 1, -1 -1 -1 -1 1, -1 1 1 1 1];
Six= [1 1 1 1 -1, 1 -1 -1 -1 -1, 1 -1 -1 -1 -1, 1 1 1 1 -1, 1 -1 -1 1 -1, 1 -1 -1 1 -1, 1 1 1 1 -1];
Seven= [-1 -1 1 1 1, -1 -1 1 1 1, -1 -1 -1 -1 1, -1 -1 -1 -1 1, -1 -1 -1 -1 1, -1 -1 -1 -1 1, -1 -1 -1 -1 -1];
Eight= [1 1 1 1 1, 1 -1 -1 -1 1, 1 -1 -1 -1 1, 1 1 1 1 1, 1 -1 -1 -1 1, 1 -1 -1 -1 1, 1 1 1 1 1];
Nine= [1 1 1 1 -1, 1 -1 -1 1 -1, 1 1 1 1 -1, -1 -1 -1 1 -1, -1 -1 -1 1 -1, -1 -1 -1 1 -1, -1 -1 -1 1 -1];
Plus= [-1 -1 -1 -1 -1, -1 -1 1 -1 -1, -1 -1 1 -1 -1, 1 1 1 1 1, -1 -1 1 -1 -1, -1 -1 1 -1 -1, -1 -1-1 -1 -1 ];
Minus= [-1 -1 -1 -1 -1,-1 -1 -1 -1 -1,-1 -1 -1 -1 -1,1 1 1 1 1, -1 -1 -1 -1 -1,-1 -1 -1 -1 -1,-1 -1 -1 -1 -1, ];
Zero= [ 1 1 1 1 1, 1 1 1 1 1, 1 -1 -1 -1 1, 1 -1 -1 -1 1, 1 -1 -1 -1 1, 1 1 1 1 1, 1 1 1 1 1];
%Patterns= [One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Plus, Minus];
%w=One*One'+Two*Two'+Three*Three'+Four*Four'+Five*Five'+Six*Six'+Seven*Seve
%n'+Eight*Eight'+Nine*Nine'+Plus*Plus'+Minus*Minus';
w=0;
rows= 7; columns= 5;
Patterns= [One, Two, Four, Five, Six, Seven, Eight, Nine, Minus];
for loop=1:min(size(Patterns))
w=w+ Patterns(:,loop)*Patterns(:,loop)';
end
w=w-w(1,1)*eye(length(w));
for kk=1:min(size(Patterns))
E(kk)= -0.5*Patterns(:,kk)'*w*Patterns(:,kk);
end
% for outerloop=1:min(size(Patterns))
input_char=[-1 -1 1 -1 -1, -1 1 1 1 -1, 1 -1 -1 -1 1, -1 -1 -1 1 -1, -1 -1 1 -1 -1, -1 1 -1 -1 1,1 1 1 1 1];
output_char= input_char;
%Natural order updation
E_pat=-0.5*input_char'*w*input_char;
E_pat_new= E_pat;
flag=1;
iteration=0; while(flag)
iteration= iteration +1;
for kk=1:length(Patterns)
output_char(kk)= sign(w(kk,:)*output_char);
end
E_pat= E_pat_new;
E_pat_new=-0.5*output_char'*w*output_char;
if E_pat== E_pat_new
flag= 0;
elseif iteration >=250
flag= 0;
end
end
for loop=1:rows
char_in(loop,:)=input_char(((loop-1)*columns+1):((loop-1)*columns+columns))';
char_out(loop,:)=output_char(((loop-1)*columns+1):((loop-1)*columns+columns))';
end
figure('Position', [431 273 381 518]);
subplot(211);imagesc(char_in);title('Input pattern', 'FontSize', 16);
subplot(212);imagesc(char_out);title('Output pattern', 'FontSize', 16);

Best Answer

Some of your vectors have 34 elements and others have 35. If you want to concatenate them in a matrix, then please make them consistent.
If you want to just put them in a long row or column vector that is possible.