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에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by