matlab 调用函数

来源:百度知道 编辑:UC知道 时间:2024/06/21 04:41:01
帮忙看看是什么问题,急死了的
function[p,pmax,pmin,pn]=Z(f,g)
%IMPROD Computes the produce of two images.
%[P,PMAX,PMIN,PN]=IMPROD(F,G) outputs the element-by-element
%product of two input images,F and G,the product
%maximum and minimum values,and a normalized product array with
%values in the rang[0,1].The input images must be of the same
%size.They can be of class uint8,uint16,or double. The outputs
%are of class double.
fd=double(f);
gd=double(g);
p=fd.*gd;
pmax=max(p(:));
pmin=min(p(:));
pn=mat2gray(p);

之后,我定义了一个

>> f=[1 2;3 4];
>> g=[1 2;2 1];

运行
>> [p,pmax,pmin,pn]=improd(f,g)

出的提示??? Undefined command/function 'improd'.

是怎么回事?
帮帮忙

函数名……
function[p,pmax,pmin,pn]=improd(f,g)
%这里:你命名函数为Z,却调用improd肯定不行……
%IMPROD Computes the produce of two images.
%[P,PMAX,PMIN,PN]=IMPROD(F,G) outputs the element-by-element
%product of two input images,F and G,the product
%maximum and minimum values,and a normalized product array with
%values in the rang[0,1].The input images must be of the same
%size.They can be of class uint8,uint16,or double. The outputs
%are of class double.
fd=double(f);
gd=double(g);
p=fd.*gd;
pmax=max(p(:));
pmin=min(p(:));
pn=mat2gray(p);

最后,要把这个文件命名为improd.m (和函数名相同)
这样才可以用improd调用