Nodal admittance matrix using for loop and if statement
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
yu yue
am 16 Okt. 2016
Kommentiert: Andrei Bobrov
am 16 Okt. 2016
I want to ask how can I get the matrix Y if I have the value of y1, y12, y13, y23,...,etc.
I have coding as below, but it dose not work. Who can help me?
B_matrix =[0 2.5000 0 1.6667 5.0000 0; -2.5000 0 5.0000 2.5000 0 0;0 -5.0000 0 0 5.0000 0; -1.6667 -2.5000 0 0 0 0; -5.0000 0 -5.0000 0 0 0; 0 0 0 0 0 0]
Y=zeros(6,6);
for m=1:6
for n=1:6
if m==n
for (k=1:6) & (k ~ = m)
Y(m,n)=B_matrix(m,n)+B_matrix(m,k);
else
Y(m,n)=-B_matrix(m,n);
end
end
end
end
Y
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 16 Okt. 2016
Y = diag(sum(B_matrix,2)) - (~eye(size(B_matrix))).*B_matrix;
2 Kommentare
Andrei Bobrov
am 16 Okt. 2016
aB = abs(B_matrix);
Y = diag(sum(aB,2)) - (~eye(size(B_matrix))).*aB;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!