How to solve the error?

1 次查看(过去 30 天)
Darsana P M
Darsana P M 2018-4-26
回答: Jon 2018-4-26
for k=1:3:22
for l=1:3:22
for i=1:b:M
for j=1:b:N
Block(l,k)=L0(i:i+b-1,j:j+b-1);
A=zeros(200,200);
A=Block;
n1=double(Block).*Rot;
L1=mod(n1,N);
%K=A1;
% R1=(L1 + double(A1))
% m=mod(R1,N);
%A2=L0(4:6,1:3);
end
end
end
end
I have an image,198x198 matrix. I wanted to get 3x3 matrix,each, from the image and do certain operations. Rot=3x3 matrix R0=200x200 matrix. if i take 3x3 matrix each, from the image, i will get 22 matrices in total. In the program, I want to repeat the process 22 times, so i introduced,k and l terms. But i got an error: Subscripted assignment dimension mismatch.
Error in daru (line 37)
Block(l,k)=L0(i:i+b-1,j:j+b-1);
Can somebody help me with a loop to repeat it 22 times?
  3 个评论
Darsana P M
Darsana P M 2018-4-26
Yes sir,But it is a different code. I have been trying this the whole day. I am trying different codes,but none give me the results. Could somebody help me to solve this.
Darsana P M
Darsana P M 2018-4-26
I am weak in using for loops. Can anyone help me out?

请先登录,再进行评论。

回答(1 个)

Jon
Jon 2018-4-26
Look closely at your your assignment statement, Block(l,k)=L0(i:i+b-1,j:j+b-1). The left hand side, Block(l,k) is a scalar value. It is just the value of the element in row l, column k, of a matrix called Block. The right hand side is is a matrix with b rows and b columns. You are trying to assign this matrix to a scalar value. The error message is telling you that this does not make sense. You can not assign a matrix to something that should be a scalar value.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by