我尝试使用 fitgmdist.m 来拟合高斯混合模型。但是,当它调用类 gmdistribution 的构造函数时。我得到错误的messgae如下:
错误:在索引表达式中无效使用脚本/home/ubuntu/UAVProject_DataStructure/gmdistribution.m 错误:来自: 错误:/home/ubuntu/UAVProject_DataStructure/fitgmdist.m第505行第7行 错误:/home/ubuntu/UAVProject_DataStructure/computeGMM.m第78行第10栏 错误:/home/ubuntu/UAVProject_DataStructure/ImageProcessing.m第18行第13列
我在当前目录中放了2个文件: fitgmdist.m 和 gmdistribution.m 。
我还更改了gmdistribution.m名称以避免使用与八度音程库文件相同的名称,但它不起作用。有人可以帮忙吗?感谢。
这里调用构造函数代码:
obj = gmdistribution (best_params.mu, best_params.Sigma, best_params.p');
这是构造函数代码:
########################################
## Constructor
function obj = gmdistribution (mu,sigma,p = [],extra = [])
obj.DistributionName = "gaussian mixture distribution";
obj.mu = mu;
obj.Sigma = sigma;
obj.NumComponents = rows (mu);
obj.NumVariables = columns (mu);
if (isempty (p))
obj.ComponentProportion = ones (1,obj.NumComponents) / obj.NumComponents;
else
if any (p < 0)
error ("gmmdistribution: component weights must be non-negative");
endif
s = sum(p);
if (s == 0)
error ("gmmdistribution: component weights must not be all zero");
elseif (s != 1)
p = p / s;
endif
obj.ComponentProportion = p(:)';
endif
if (length (size (sigma)) == 3)
obj.SharedCovariance = false;
else
obj.SharedCovariance = true;
endif
if (rows (sigma) == 1 && columns (mu) > 1)
obj.DiagonalCovariance = true;
obj.CovarianceType = 'diagonal';
else
obj.DiagonalCovariance = false; ## full
obj.CovarianceType = 'full';
endif
if (!isempty (extra))
obj.AIC = extra.AIC;
obj.BIC = extra.BIC;
obj.Converged = extra.Converged;
obj.NegativeLogLikelihood = extra.NegativeLogLikelihood;
obj.NlogL = extra.NegativeLogLikelihood;
obj.NumIterations = extra.NumIterations;
obj.RegularizationValue = extra.RegularizationValue;
endif
endfunction