About Choosing MATRIX element
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
function[Ybus] = ybus(zdata) %first function
nl=zdata(:,1); nr=zdata(:,2); R=zdata(:,3); X=zdata(:,4);
nbr=length(zdata(:,1)); nbus = max(max(nl), max(nr));
Z = R + j*X;
y= ones(nbr,1)./Z;
Ybus=zeros(nbus,nbus);
for k = 1:nbr;
if nl(k) > 0 & nr(k) > 0
Ybus(nl(k),nr(k)) = Ybus(nl(k),nr(k)) - y(k);
Ybus(nr(k),nl(k)) = Ybus(nl(k),nr(k));
end
end
for n = 1:nbus
for k = 1:nbr
if nl(k) == n | nr(k) == n
Ybus(n,n) = Ybus(n,n) + y(k);
else, end
end
end
% From To R X ---these are from circuit second function
z = [ 1 2 0.12 0.16
2 3 0.032 0.012
3 4 0.001 0.1
3 5 0.002 0.015];
[Ybus] = ybus(z) % bus admittance matrix
Hello,
I would like to choose every element of a matrix with for loop. I mean first I need to select 1st. element then I need to save it to a variable. Then second. thirt... etc.
The matrix that I mention has real and imaginer side in every element. Like;
[Ybus] = ybus(z) % bus admittance matrix
YBara =
3.0000 - 4.0000i -3.0000 + 4.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
-3.0000 + 4.0000i 30.3973 -14.2740i -27.3973 +10.2740i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i -27.3973 +10.2740i 36.2309 -85.7752i -0.1000 + 9.9990i -8.7336 +65.5022i
0.0000 + 0.0000i 0.0000 + 0.0000i -0.1000 + 9.9990i 0.1000 - 9.9990i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i -8.7336 +65.5022i 0.0000 + 0.0000i 8.7336 -65.5022i
Who can help me? Thank you.
REgards.
0 commentaires
Réponses (1)
Deepak Meena
le 17 Nov 2020
Hi,
I think you want to know how you acces the array elements in a for loop. You can refer to this documentations:
0 commentaires
Voir également
Catégories
En savoir plus sur Pattern Recognition and Classification dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!