Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

In which format I have to give the inputs?

조회 수: 2 (최근 30일)
Haritha
Haritha 2018년 8월 25일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi,
I want to optimize heat exchanger design parameters I am creating an objective function for that. a = temp parameters, b = pressure parameters, c= cost variation
I have the code as function a = objfun(a,b,c)
my output will be a(1) b(1) c(1) a(2) b(2) c(2) a(3) b(3) c(3) . . . . . . . . . . . . . . .
In which format I have to give the inputs?
  댓글 수: 1
Rik
Rik 2018년 8월 25일
What the input should be like, depends on what your function is actually doing.
Have a read here (or here for more general advice) and here. It will greatly improve your chances of getting an answer.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 8월 25일
Example:
abc0 = randi(10, 3, 4);
bestabc = fmincon(@objfun, abc0(:));
function cost = objfun(abc)
abc = reshape(abc, [], 3);
a = abc(:,1);
b = abc(:,2);
c = abc(:,3);
cost = ....
That is, you can create an array of initial values for your purpose, but you will need to reshape it as a vector to pass in to the optimization. However, in your objective function you can reshape as an array again and then extract appropriate parts of it.

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by