"Output argument "xxx" (and maybe others) not assigned during call" and "if statement" problem
9 views (last 30 days)
Show older comments
Hello everyone.
I'm having a bit of trouble with some matlab code and was wondering could you help. I have introduced some 'if' statements into my code to pad an array with zeros. I have done this as the correlation function will not work if the arrays/vectors are of different lengths. However, since the introduction of the statements, I am getting the following error;
*Error in ==> comparescan at 3
imAx = imread('rh1ro5.bmp'); %reads in the handprint
??? Output argument "linearftAx" (and maybe others) not assigned during call to "C:\Users\Documents\MATLAB\comparescan.m>comparescan".
The code is as follows;*
function [imAx, ftAx, linearftAx] = comparescan(varargin)
imAx = imread('rh1ro5.bmp'); %reads in the handprint
%imAn = imnoise(imA,'salt & pepper', 0.002);
BWA = rgb2gray(imAx);
BW1A = roicolor(BWA,50,500); %creates a binary mask of the image
BW2A = bwareaopen(BW1A, 50); %removes anything less than 50 connected pixels
BW3A = bwperim(BW2A,8); %draws a boundary around the binary mask
imwrite(BW3A,'contour.bmp','bmp');
IA = imread('contour.bmp');
[RaA cxA cyA] = max_inscribed_circle(IA);
BWcropA = circlecrop(BWA,RaA,cxA,cyA);
BWcropA1 = BWcropA(any(BWcropA'),any(BWcropA));
[PC, or, ft, T] = phasecongmono(BWcropA1);
global ftA
global linearft
ftAx = ft;
imwrite(BWcropA1,'compare.bmp','bmp');
L1 = length(ftA);
L2 = length(ftAx);
P=(L1-L2)/2;
Q=(L2-L1)/2;
if (L2<L1);
Pad1 = padarray(ftAx,[P P]);
linearftAx=reshape(Pad1,[],1);
return
end
if (L1<L2);
Pad2 = padarray(ftA,[Q Q]);
linearft=reshape(Pad2,[],1);
end
I can't see what's wrong here. I understand that 'linearftAx' isn't returning a value to the output argument of the function, but I don't know why as the variable is declared in the if statement.
0 Comments
Answers (1)
Image Analyst
on 18 Sep 2011
Apparently it never gets inside the "if" statements to make the assignment. You should put
linearftAx = 0;
at the start of your function just to ensure that it has something to return.
5 Comments
Walter Roberson
on 22 Sep 2011
But you have a "return" if L2<L1 so corrcoef would not be called in that case.
See Also
Categories
Find more on MATLAB Mobile Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!