다스탯 방정식의 최적 포인트를 날값으로 뽑아주는 함수인데스
삼변수도 사변수도 행복 플로팅
function optPoint = getOptPoint(f,upperNumber,slice)
optPoint = cell(1,slice);
delta = upperNumber/slice;
argNum = getArgNum(f);
for i = 1:slice
prob = optimproblem('ObjectiveSense','max');
x = optimvar('x',argNum,'LowerBound',0);
varCell = num2cell(x);
prob.Objective = f(varCell{1:argNum});
cons1 = sum(x)<=(i*delta);
prob.Constraints.cons1 = cons1;
for j = 1:argNum
x0.x(j) = 0;
end
optPoint{i} = solve(prob,x0);
end
end
function result = getArgNum(func)
result = length(strfind(func2str(func),','))+1;
end
f는 익명 함수 핸들 upperNumber는 최대 옵션 수 slice는 분할 해상도
이걸로 값을 먼저 뽑고
function result = splitToAxisVector(someCell)
len_someCell = length(someCell);
len_innerStruct = length(someCell{1}.x);
result = cell(len_innerStruct,1);
for i = 1:len_innerStruct
result{i} = zeros(1,len_someCell);
end
for j = 1:len_someCell
for k=1:len_innerStruct
result{k}(1,j) = someCell{j}.x(k);
end
end
end
이걸로 plot이나 plot3에 쓸 수 있는 형태로 바꾸면 됨
optimization 툴박스 필수
이번달 매트랩 무료시간 거의 쫑나서 추가검증은 몰루
2변수는 직관의 영역에서 이미 잘 아니깐 확실히 된다고 말할 수 있는데
3변수 이상은 시발 맞겠지? 개념적으론 맞는게 맞는데 말이야