Error using / Matrix dimensions must agree.
Show older comments
Hello everyone, can you please help me with this problem? I currently in my project's for Iterative Method. But I can't run the coding because of this problem.
Delamda = DelP/J;
Attached below is my full coding, can you guys help me?
clear
clc
a = [671 574 374 374 461 630 548 227 173 175 186 230 225 309 323];
b = [10.1 10.2 8.8 8.8 10.4 10.1 9.8 11.2 11.2 10.7 10.2 9.9 13.1 12.1 12.4];
c = [0.000299 0.000183 0.001126 0.001126 0.000205 0.000301 0.000364 0.000338 0.000807 0.001203 0.003586 0.005513 0.000371 0.001929 0.004446];
PD = 2630;
DelP = 10;
% define fuel cost quaratic equation
cost = [671 10.1000 0.000299
574 10.2000 0.000183
374 8.8000 0.001126
374 8.8400 0.001126
461 10.4000 0.000205
630 10.1000 0.000301
548 9.8000 0.000364
227 11.2000 0.000338
173 11.2000 0.000807
175 10.7000 0.001203
186 10.2000 0.003586
230 9.9000 0.005513
225 13.1000 0.000371
309 12.1000 0.001929
323 12.4000 0.004446];
% define Pi_min and Pi_max
mwlimits = [150 455
150 455
20 130
20 130
150 470
135 460
135 465
60 300
25 162
25 160
20 80
20 80
25 85
15 55
15 55];
Pdt = 2630;
lamda = input('Enter estimated value of Lamda = ');
fprintf(' ')
disp ['Lamda P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 DP'...' grad Delamda'];
iter = 1;
while abs(DelP) >= 0.001
iter = iter + 1;
P = (lamda - b)./(2*c);
DelP = PD - sum(P);
J = sum(ones(length(a),1)./(2*c));
Delamda = DelP/J;
disp [lamda,P(1),P(2),P(3),P(4),P(5),P(6),P(7),P(8),P(9),P(10),P(11),P(12),P(13),P(14),P(15)DelP,J,Delamda];
lamda = lamda + Delamda;
end
totalcost = sum(a + b.*P + c.*P.^2);
4 Comments
Rik
on 5 Jan 2021
Without an appropriate value as the initial estimated value of Lambda we can't run your code. Also, please chech if this is indeed the syntax you mean.
More importantly: what are you trying to do? Your code is devoid of any comment, so it is difficult to understand what you intend it to do.
Muhammad Ezree Amree bin Amran
on 5 Jan 2021
Hadi Jalali
on 25 Feb 2021
Hi friends. I want to need a code to solve ELD by third degree cost fuel. But I have no idea. Please help me Best wishes H. Jalali
Rik
on 25 Feb 2021
@Hadi Jalali That sounds like a poorly phrased question unrelated to this one. Have a read here and here. It will greatly improve your chances of getting an answer.
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!