How to solve : Subscripted assignment dimension mismatch error
1 次查看(过去 30 天)
显示 更早的评论
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
1 个评论
采纳的回答
bahar kh
2017-5-26
1 个评论
Andrei Bobrov
2017-5-26
>> A=randi(10,2,3)
A =
9 2 7
10 10 1
>> A(1,1) = 2
A =
2 2 7
10 10 1
>> A(2,1) = 'no'
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
>> double('no')
ans =
110 111
>>
更多回答(1 个)
Andrei Bobrov
2017-5-26
Use cell - array ( Aout) for output data in your function
A=randi(10,2,3);
Aout = cell(size(A);
for i=1:2
for j=1:3
if A(i,j)>3
Aout{i,j}='ok';
elseif A(i,j)==2
Aout{i,j}='no'
else
Aout{i,j}=' ';
end
end
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!