How do I solve this particular error? First-time MATLAB user

This is the code I'm trying to run:
%Blind embedding and linear correlation detection
clear all;
%Generate a reference pattern the same size as the images
wr=randn(112,92);
tm=mean2(wr);
wr=wr-tm;%zero mean
ts=std2(wr);
wr=wr/ts;%unit variance
%Show the reference pattern
figure
imshow(wr,[]);
%400 face images, 112 x 92 pixels, in 40 folders of 10 images each
numclass=40;
numface=10;
for s=1:numclass
for i=1:numface
%Read image
c0=double(imread(strcat('C:\facedb_bmp\s',num2str(s),'\', num2str(i),'.bmp')));
%Add reference pattern to the image to embed a 1
wa=double(c0+wr);
%Add negative reference pattern to the image to embed a 0
nwr=wr*-1;
nwa=double(c0+nwr);
%Calculate linear correlation for images carrying a 1, a 0,
%or no watermark and store it into a vector
corr1(10*(s-1)+i)=sum(sum(wa.*wr))/(112*92);
corr0(10*(s-1)+i)=sum(sum(nwa.*wr))/(112*92);
corrN(10*(s-1)+i)=sum(sum(c0.*wr))/(112*92);
end
end
%Calculate the histograms for the detection-value vectors
[a1,b1]=hist(corr1,-3:0.1:3);
[a2,b2]=hist(corr0,-3:0.1:3);
[a3,b3]=hist(corrN,-3:0.1:3);
%Plot the histograms
figure
plot(b2,a2/400*100,'red');
gtext('m=0');
hold;
plot(b3,a3/400*100,'green');
gtext('No watermark');
plot(b1,a1/400*100,'blue');
gtext('m=1');
xlabel('Detection value');
ylabel('Percentage of images');
if true
% code
end
When I click 'Save and Run', it gives me this error:
??? Undefined function or method 'blind' for input arguments of type 'char'.
Can anyone help me out? Also the image I'm using is Lena.tiff. I know I need to change the directory from C: onwards but do I also need to change .bmp to .tiff? Any help would be much appreciated.

Answers (2)

Looks like you are using a function 'blind': there is not such command, and probably doesnt have a made up function.
The point is you are calling an undefined function.

4 Comments

In the code though there isn't any 'blind' function that I can see. Can you please tell me where I am calling an undefined function in the code so I may change it?
There mus be in the part of the code you hided. Check for occurences of that word in your code and I think you will find it.
I believe you are mistaken, I've shown you the entirety of my code.
That's what the error message suggest.
I tried to run the code and doesn't appear any error message. Maybe the error is not the code.

Sign in to comment.

Look at your first few characters:
%Blind
If for some reason the '%' is not being recognized as a comment character then that line would be interpreted as a call to "Blind" with the rest of the line as character arguments.
What, by the way, did you name your source file? The source file name must start with a letter, and be followed by letters, digits, or underscore (no spaces) to a maximum of 63 characters, after which there should be a '.m' extension.

11 Comments

Thank you, my file name had spaces in. I've renamed the file codeA.m. I ran the program again and found a new error, maybe you can help?
??? Undefined function or method 'meanTwo' for input arguments of type 'double'.
Error in ==> codeA at 5
tm=meanTwo(wr);
The proper syntax is:
tm=mean2(wr);
Put your cursor in meanTwo and type control D. What does it say? It will probably say that there is no meanTwo on the search path and ask you if you want to write a new function called meanTwo.
Your original code showed mean2(), which is in the Image Processing Toolbox. So evidently you changed it for some reason to meanTwo(). Why? If you don't have the IPTB, you can use mean(wr(:)) instead of mean2(twr).
Sorry it was originally 'mean2' but after getting the error I tried changing '2' to 'Two' to see if the error would disappear and it didn't. Right I solved that by switching 'wr' with 'wr(:)' but now there's a NEW error again :/
??? Undefined function or method 'std2' for input arguments of type 'double'.
Error in ==> codeA at 7
ts=std2(wr);
I tried the same solution as previous for this particular error but got the same result. Any theories? I'm starting to think that I should have separate files with this code in order for it to work... If so that's really unfortunate.
Not sure what you tried, but did you try this:
ts=std(wr(:));
Thank you, new error though:
??? Undefined function or method 'imshow' for input arguments of type 'double'.
Error in ==> codeA at 11
imshow(wr,[]);
Type "ver" to see what toolboxes you have. Is the Image Processing Toolbox listed?
Sorry for the late reply. No it isn't. I'm going to try and get a hold of a more up-to-date MATLAB program.
Got a working Matlab program with the toolbox you mentioned. Used original code with no changes apart from directory and got this error:
Error using +
Matrix dimensions must agree.
Error in NewCode (line 22)
wa=double(c0+wr);
Any ideas?
Here's an idea http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/ After that, you will discover how to find the sizes of c0 and wr, and learn that they are different sizes. You can only add matrices if they are the same size, don't you agree? How could you add a 2 by 3 matrix to a 1024 by 960 matrix?
Thank you very much I learnt a lot from that video and finally ran the code successfully

Sign in to comment.

Asked:

on 12 Apr 2014

Commented:

on 21 Apr 2014

Community Treasure Hunt

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

Start Hunting!