|
原帖由 liushuiwuxin 于 2009-5-7 23:06 发表
...在另外一个M文件里怎么调用Function 里面的..
难道楼主要的是subfunction吗?
doc subfunctions
下面是matlab帮助文件内的例子
function [avg, med] = newstats(u) % Primary function
% NEWSTATS Find mean and median with internal functions.
n = length(u);
avg = mean(u, n);
med = median(u, n);
function a = mean(v, n) % Subfunction
% Calculate average.
a = sum(v)/n;
function m = median(v, n) % Subfunction
% Calculate median.
w = sort(v);
if rem(n, 2) == 1
m = w((n+1) / 2);
else
m = (w(n/2) + w(n/2+1)) / 2;
end
[ 本帖最后由 ChaChing 于 2009-5-8 15:49 编辑 ] |
|