Issue formatting MATLAB results output

1 回表示 (過去 30 日間)
Dane
Dane 2014 年 10 月 2 日
コメント済み: Dane 2014 年 10 月 3 日
I am pretty unfamiliar with MATLAB so I had someone originally help me with the code. Problem is for some reason I have the output of the function structured like below and I am getting something more akin to a status output then the actual values which would be more like the specific quantities at each given interval.
If I need to include more of the code in my description just let me know.
Output code format:
%%5) Solve optimization problem
[x,fval,exitflag,output] = intlinprog(problem);
outputString = output.message;
end
% Plot results
%bar(p1:p2,x,0.5);
%fprintf('\n\nAverage set:\t%4.2f\n',avg);
%fprintf('Average opt:\t%4.2f\n',(p1:p2)*x/N);
Resulting output:
Intlinprog stopped at the root node because the objective value is within a gap tolerance of the optimal value; options.TolGapAbs = 0 (the default value). The intcon variables are integer within tolerance, options.TolInteg
ans =
  1 件のコメント
Image Analyst
Image Analyst 2014 年 10 月 2 日
Doesn't make sense, to me at least. What does Output code format mean? It looks like code. Code that has the functions that create output, like bar() and fprintf(), commented out.
Your "Resulting output" looks more like a warning or error message than any output that your code would intentionally generate. Is it in red or orange color text, and include a traceback (line numbers and function names where the error originated)?
Have you ever seen this link. It should solve all your issues.

サインインしてコメントする。

採用された回答

Alan Weiss
Alan Weiss 2014 年 10 月 3 日
I think that you misunderstand the result. The x variable is in your workspace after intlinprog finishes. It contains the result you seek. If you want to see a plot of the result, and see some information, uncomment the plotting lines:
bar(p1:p2,x,0.5);
fprintf('\n\nAverage set:\t%4.2f\n',avg);
fprintf('Average opt:\t%4.2f\n',(p1:p2)*x/N);
Alan Weiss
MATLAB mathematical toolbox documentation
  1 件のコメント
Dane
Dane 2014 年 10 月 3 日
Thanks for the help, I was able to get it sorted out. I just didn't have the print results defined properly.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by