Error in printing number

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 commentaire

Jan
Jan le 12 Déc 2012
Modifié(e) : Jan le 12 Déc 2012
@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.

Connectez-vous pour commenter.

Réponses (1)

Jan
Jan le 12 Déc 2012
Modifié(e) : Jan le 12 Déc 2012

0 votes

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 commentaires

kash
kash le 12 Déc 2012
YEs Jan i third column of subplot i want print value of Er3 above that image
Jan
Jan le 12 Déc 2012
Does the suggestion to add the title command solve the problem? It is surprising, because you use this command one line earlier already.
Btw., using "error" as name of a variable is a bad idea, because you cannot access the important Matlab function with the same name anymore afterwards.
kash
kash le 12 Déc 2012
ok Jan i want to display values in Er3
Walter Roberson
Walter Roberson le 12 Déc 2012
Where are m131 and m111 and so on defined?
kash
kash le 14 Déc 2012
they are just variables used for subplotting
Replace
sprintf('Er3 #%d', m131);
with
title(sprintf('Er3 #%d', m131));

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Question posée :

le 12 Déc 2012

Community Treasure Hunt

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

Start Hunting!

Translated by