Error in writing function file

조회 수: 19 (최근 30일)
FIR
FIR 2012년 1월 5일
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

답변 (1개)

C.J. Harris
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'?
  댓글 수: 1
FIR
FIR 2012년 1월 5일
s it is final_col2'

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

카테고리

Help CenterFile 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!

Translated by