output for linprog to generate table view
1 次查看(过去 30 天)
显示 更早的评论
hello, I am working on making the output of my code visually nicer. yes this is homework, but I already have the correct answers and working code for the homework problem. I understand the homework, now I am attempting to just clean the output up to make it readable by others outside of the class.
if true
% code
L1 = 250;
L2 = 200;
L3 = 200;
f = [40; 50; 55; 0; 0;];
Aeq = [1 1 1 0 0 ;
0 1 0 -15 5;
0 0 1 5 -13 ];
Beq1 = [10; 3.5; 4.5];
Beq2 = [11; 3.5; 4.5];
Beq3 = [9; 3.5; 4.5];
Aineq = [0 0 0 -10 0;
0 0 0 10 0;
0 0 0 0 -8;
0 0 0 0 8;
0 0 0 -5 5;
0 0 0 5 -5];
Bineq = [L1;L1;L2;L2;L3;L3]/100;
lb = [0; 0; 0; -pi; -pi];
ub = [8.2; 6; 6.1; pi; pi ];
% Hour 1
fprintf('Homework #2 problem #1 EEL-4932 Intro to Smart Grid Spring 2016.\n')
fprintf('Raymond L. Brunkow\n\n')
[x,fval,exitflag,output,lambda] = linprog(f, Aineq, Bineq, Aeq, Beq1, lb, ub);
x(1)=x(1)*100;
x(2)=x(2)*100;
x(3)=x(3)*100;
cost = 40*x(1) + 50*x(2) + 55*x(3);
fprintf('\nThe cost for hour 1 is $%4.2f per MW.\n',cost);
fprintf('The following values for PG1, PG2, PG3, Gamma 2, and Gamma 3 are as follows:\n');
disp(x);
end
That is the working code. For Beq2 & 3 the output sections are the same for hours 2 and 3 so no need to copy/paste them here.
The output I am getting is as follows:
if true
% code
The cost for hour 1 is $44750.00 per MW.
The following values for PG1, PG2, PG3, Gamma 2, and Gamma 3 are as follows:
650.0000
100.0000
250.0000
-0.2500
-0.2500
end
What I would like to do is somehow in a matrix or table like output add the following vector/column:
if true
% code
PG1
PG2
PG3
Gamma 2
Gamma 3
end
Such that they line up with the output from linprog to look something like:
if true
% code
The cost for hour 1 is $44750.00 per MW.
The following values for PG1, PG2, PG3, Gamma 2, and Gamma 3 are as follows:
PG1 650.0000
PG2 100.0000
PG3 250.0000
Gamma 2 -0.2500
Gamma 3 -0.2500
end
Is that even possible? If so how? If not, well that is good too.
Thank you all in advance.
0 个评论
采纳的回答
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!