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 Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by