Error in printing number

조회 수: 9 (최근 30일)
kash
kash 2012년 12월 12일
I have a code below in which i have error in printing value at the third column
for m3 = 1:(length(dirlist))
I = imread([pathname, dirlist(m3).name]);
A=rgb2gray(I);
A=imresize(A,[256 256]);
J2 = imnoise(A,'salt & pepper',0.2);
Q1=cao(J2);
Q1=imresize(Q1,[256 256]);
Er3= mean2((single(A) - single(Q1)).^2);
error(m3)= mean2((single(A) - single(Q)).^2);
PS(m2) = 20 * log10 (255 / sqrt(Er3));
figure(4),subplot(4,3,m111),imshow(A),title('Original Image')
subplot(4,3,m121),imshow(J2),title('Noise Image')
subplot(4,3,m131),imshow(Q1)
sprintf('Er3 #%d', m131);
m111=m111+3;m121=m121+3;m131=m131+3;
end
I want to print value in Er3 in third column,its not printing ,please help
  댓글 수: 1
Jan
Jan 2012년 12월 12일
편집: Jan 2012년 12월 12일
@kash: You are the most frequently asking users of this forum. Please, help us to improve the quality of this forum by improving the quality of the questions. Omit all unnecessary lines of code and concentrate on the essential parts. Use code formatting for the code only, not for the complete message. Please read your own question after typing it and check, if a reader has the chance to recognize what you want to explain. Accept answers, which solve your problem. On one hand this is friendly, on the other hand it shows, that readers can care about other threads instead.

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

답변 (1개)

Jan
Jan 2012년 12월 12일
편집: Jan 2012년 12월 12일
The code contain a bunch of lines, which do not concern the problem. Posting only the relevant code is more efficient.
Perhaps you mean this line:
sprintf('Er3 #%d', m131);
This creates a string, but does not store it anywhere. Therefore is is useless. Do you mean fprintf to write to the command line? But what does "in third column" mean? Do you want this string to appear as title for the subplot in the 3rd column? Then simply add a title() command and use the sprintf command as argument.
  댓글 수: 6
kash
kash 2012년 12월 14일
they are just variables used for subplotting
Walter Roberson
Walter Roberson 2012년 12월 14일
Replace
sprintf('Er3 #%d', m131);
with
title(sprintf('Er3 #%d', m131));

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by