please help me in this code how to over come from this error i will be posting my code

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);

5 Comments

format the code and post the actual error message.
??? Error using ==> horzcat, CAT arguments dimensions are not consistent.
This is the error
Posting the error message means actually posting the complete error message, which include the line, which causes the error.
??? Error using ==> horzcat
CAT arguments dimensions are not consistent.
Error in ==> feed1 at 19
Patterns=[One, Two, Four, Five, Six, Seven, Eight, Nine, Minus];
i got the answer for this thank you very much for the help

Sign in to comment.

 Accepted 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.

2 Comments

how should i do that
now i m getting ds error
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> feed1 at 38
output_char(kk)= sign(w(kk,:)*output_char);

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!