MATLAB: How to solve : Subscripted assignment dimension mismatch error

dimension mismatchMATLAB

Dear guys I am new in MATLAB. It is a simple code which i make it. but i get this error message"Subscripted assignment dimension mismatch." I dont know whats the problem with that. would you please help me?
A=[]
A=randi(10,2,3)
for i=1:2
for j=1:3
if A(i,j)>3
A(i,j)='ok';
elseif A(i,j)==2
A(i,j)='no'
else
A(i,j)=' ';
end
end
end

Best Answer

still I have a question.when I change the code to the following form it works too.why? the last code and new one, almost are the same. but why the original code in my question doesn't work but the modified version works? what is the difference between them? thanks in advance
the modifiied version is here A=[] A=randi(10,2,3) for i=1:2 for j=1:3 if A(i,j)>3 A(i,j)=0; elseif A(i,j)==2 A(i,j)=2 else A(i,j)=6; end end end