How to solve 'n' number system of equations
2 views (last 30 days)
Show older comments
What I am trying to do here is find PL as equation of variables, then differentiate it to find dpl/dpi ,subtitute it in this formula
where Li is written as k in my code then multiply it with df(i) and equate it to L which is 10.
The issue is if i length of 'a' is 2 then this code will work properly but if length of 'a' is greater than 2, this will cause for k(i)*df(i) to have more than one variable inside ( p1, p2 ,p3 ...) and i cant solve the system. I tried to convert it to matrix and solve it but it was not possible due to it being non linear.
clc
clear
a=[0.012;0.018;0.014];%The cofficeient next to power in the IFC equation
ng =length(a);
syms p [1 ng]
symvar Y
L=10;%Value of lambda
b=[7,6.3,6.8];%The cofficeientin the IFC equation
B=[0.1 0.01 0.01; 0.01 0.13 0.02; 0.01 0.02 0.04];
for i=1:length(a)
for j=1:length(a)
pl(j,i) = p(i)*B(i,j)*p(j);
end
Pl(i) = sum(pl(:,i));
end
Pl = sum(Pl);
for i=1:length(a)
df(i)=a(i)*p(i)+b(i);
dp(i)=diff(Pl,p(i));
k(i)=1./(1-dp(i));
Y(i)=linsolve(k(i)*df(i)==L,p(i))
plc=subs(pl(i),Y(i));
n(i)=sum(plc);
end
pt=sum(Y)-plc;
disp('The value of Power of each plant respectively in a matrix are')
disp((Y))
fprintf('The value of power losses is = %f ',abs(plc))
fprintf('\nThe value of total power is = %f ', abs(pt))
0 Comments
Accepted Answer
Matt J
on 26 Dec 2022
Edited: Matt J
on 26 Dec 2022
It appears to me that the equation can be re-arranged quite easily into a set of linear equations in P,
or
which is easily solved in one line:
a=[0.012;0.018;0.014];%The cofficeient next to power in the IFC equation
b=[7,6.3,6.8];
L=10;%Value of lambda
B=[0.1 0.01 0.01; 0.01 0.13 0.02; 0.01 0.02 0.04];
P=(B+diag(a)/(2*L)) \ (1 - b(:)/L )/2
4 Comments
Matt J
on 26 Dec 2022
Edited: Matt J
on 26 Dec 2022
Isn't the equation you ultimately want to satisfy k.*df=10? The code below demonstrates that this is achieved:
a=[0.012;0.018;0.014];%The cofficeient next to power in the IFC equation
b=[7;6.3;6.8];
L=10;%Value of lambda
B=[0.1 0.01 0.01; 0.01 0.13 0.02; 0.01 0.02 0.04];
P=(2*B + diag(a/L)) \ (1 - b./L )
dp=2*B*P;
df=a.*P+b;
k=1./(1-dp);
k.*df %Check the original equation
We can also verify the equations you presented, though they still are somewhat obscure to me:
[p1,p2,p3]=deal(P(1),P(2),P(3));
503*p1 + 50*p2 + 50*p3 == 750
100*p1 + 1309*p2 + 200*p3 == 1850
100*p1 + 200*p2 + 407*p3 == 1600
More Answers (0)
See Also
Categories
Find more on Assumptions 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!