function [A,possi] = MLM_CON(P,E) [~,nEnd] = size(E); [~,nPix] = size(P); initX = hyperFcls(P,E); A = zeros(nEnd,nPix); possi = zeros(1,nPix); Aeq = [ones(1,nEnd),0]; beq = 1; ub = ones(1,nEnd+1); lb = [zeros(1,nEnd),-inf]; options = optimoptions('fmincon','Display','off','OptimTolerance',1e-10,'ConstraintTolerance',1e-8); %options = optimoptions('fmincon','Display','off','OptimalityTolerance',1e-10,'ConstraintTolerance',1e-8); for i = (1:nPix) objFun = @(x)object(x,P(:,i),E); x0 = [initX(:,i)',0]; x = fmincon(objFun,x0,[],[],Aeq,beq,lb,ub,[],options); A(:,i) = x(1:nEnd); possi(i) = x(nEnd+1); end end function fit = object(para,pix,E) para = para'; [nvars,nPop] = size(para); nEnd = nvars - 1; % 初始化y alpha = para(1:nEnd,:); possi = para(nvars,:); y = E * alpha; extPix = repmat(pix,1,nPop); fit = vecnorm(extPix - ((1 - possi) .* y) ./ (1 - possi .* y) ).^2; end这段非线性混合像元分解代码为什么在matlab2014a中运行不了,怎么修改才可以运行
时间: 2023-09-27 08:10:42 浏览: 84
这段代码可能会在MATLAB 2014a中出现问题,因为fmincon的默认算法可能不支持非线性约束条件。可以尝试修改options选项,将算法从默认的interior-point改为sqp。可以使用以下代码替换原来的options行:
options = optimoptions('fmincon','Display','off','OptimTolerance',1e-10,'ConstraintTolerance',1e-8,'Algorithm','sqp');
如果问题仍然存在,可能需要升级MATLAB版本或者使用其他非线性优化函数来替换fmincon函数。
阅读全文