matlab中子函数为什么调用不对?是函数的功能实现不对吗

子函数function [n]=calculate_histogram(PS, nBins)
% img gray scale image ranging from [0, 255]
% nBins number of the histogram bins
% output histogram vector
img=imread(PS);
n=imhist(img,nBins);% 直方图的结果是一个向量,每一位对应一个统计数值,相应灰度值的像素个数直接访问就好了

子函数的调用
[n]=calculate_histogram('C:\Users\Administrator\Desktop\新建文件夹\brightness and contrast\gaoyuanyuan.jpg',100);n

错误
Undefined function 'calculate_histogram' for input arguments of type 'char'.

你的calculate_histogram.m文件所在目录有没有添加到路径?

你把这个文件放到你的当前目录下,再运行一下,看有没有问题。
温馨提示:答案为网友推荐,仅供参考
相似回答