The expression to the left of the equals sign is not a valid target for an assignment. ...? Error in line 3rd, " minOfBlocks = zeros(16,16); " ... Help me plz

조회 수: 1 (최근 30일)
I=imread('pepper.png');
c = mat2cell(I, [32 32 32 32 32 32 32 32 32 32 32 32 32],...[32 32 32 32 32 32 32 32 32 32 32 32]);
minOfBlocks = zeros(16,16);
subplot(1,2,1);
imshow(I);
title('Original Image', 'FontSize', 30);
for i=1:16
for j=1:16
a = c{i,j};
minOfBlocks(i,j)=min(a(:));
end
end
subplot(1,2, 2);
imshow(minOfBlocks, []);
title('Min of 32x32 Blocks', 'FontSize', 30);
  댓글 수: 1
Matthew Eicholtz
Matthew Eicholtz 2016년 2월 22일
I am having trouble reproducing your error. I see nothing explicitly wrong with the third line of code. Also, no need to say "Help me plz"; it won't get you answers any faster, I promise.

댓글을 달려면 로그인하십시오.

답변 (2개)

Steven Lord
Steven Lord 2016년 2월 22일
Did you literally type ... in the middle of the second line? If so, MATLAB is waiting for you to finish that function call on the next line and assigning a value into a variable in the middle of a function call is not allowed. Either remove the ellipsis (...) or move the code that follows it onto the next line.

Jan
Jan 2016년 2월 22일
편집: Jan 2016년 2월 22일
The ellipsis "..." is an implicit comment starter also. So everyting right from '...' is ignorend, such that Matlab try to run:
c = mat2cell(I, [32 32 32 32 32 32 32 32 32 32 32 32 32],...
minOfBlocks = zeros(16,16);
As Steven told already insert a line break after the '...':
c = mat2cell(I, [32 32 32 32 32 32 32 32 32 32 32 32 32],...
[32 32 32 32 32 32 32 32 32 32 32 32]);
minOfBlocks = zeros(16,16);
By the way: The bunch of "32" is hard to debug. This is easier to read:
c = mat2cell(I, repmat(32, 1, 13), repmat(32, 1, 12));
  댓글 수: 1
shiv
shiv 2016년 2월 23일
Sir, Actually i am new in MATLAB.. I will replace c = mat2cell(I, [32 32 32 32 32 32 32 32 32 32 32 32 32],...[32 32 32 32 32 32 32 32 32 32 32 32]); with c = mat2cell(I, repmat(32, 1, 13), repmat(32, 1, 12));
then the error is Error using mat2cell (line 80) Number of input vector arguments, 2, does not match the input matrix's number of dimensions, 3.
Error in blks (line 17) c = mat2cell(I, repmat(32, 1, 13), repmat(32, 1, 12));

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by