Error in writing function file
조회 수: 19 (최근 30일)
이전 댓글 표시
I have a program ,need to create function file for it,i get error wen i create a function file
path='D:\dataset\'
files=dir(strcat(path,'*.jpg'));
for k=1:numel(files)%numel(files)
file_name=files(k).name;
image_name=strcat(path,file_name);
I=imread(image_name);
I=imresize(I,[256 256]);
size(I)
m = mean(I(:));
I1=double(I);
V = var(double(I(:)));
J = stdfilt(I);
SD = std(double(I(:)));
result=[m V SD];
final_col2{k}=result;
end
save('final_col_new','final_col2');
i wrote function file as
function k=colour1(I)
size(I)
m = mean(I(:));
I1=double(I);
V = var(double(I(:)));
J = stdfilt(I);
SD = std(double(I(:)));
result=[m V SD];
final_col2{k}=result;
end
Undefined function or variable "k".
Error in ==> colour1 at 13
final_col2{k}=result;
Error in ==> new1 at 11
colour1(I)
please help
댓글 수: 0
답변 (1개)
C.J. Harris
2012년 1월 5일
Your function specifies 'k' as an output, yet within the function you use it as an input. There set 'k' as an input in addition to 'I'. Also, you need to determine what the output from your function is - is it 'final_col2'?
참고 항목
카테고리
Help Center 및 File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!