Error in writing function file

2 次查看(过去 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'?

标签

Community Treasure Hunt

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

Start Hunting!

Translated by