Index in position 2 exceeds array bounds (must not exceed 4).

12 visualizzazioni (ultimi 30 giorni)
data=[0 1 0 0.1j
1 6 0 0.6j
1 3 0 0.2j
3 6 0 0.5j
3 4 0 0.2j
4 6 0 0.3j
2 4 0 0.4j
1 2 0 0.2j
2 5 0 0.3j
6 7 0 0.4j];
[row,col]=size(data);
order=col
for m=1:row
data(m,8)=1/(data(m,7)+data(m,8));
end
Z2adm=data;
Y=zeros(order,order);
for i=1:row
for j=1:order
if data(i,1)==0||data(i,2)==0
a=0;
elseif data(i,1)~=0||data(i,2)~=0
Y(data(i,1),data(i,2))=-data(i,8);
Y(data(i,2),data(i,1))=-data(i,8);
end
end
end
%2-digonal values
for a=1:order %for k
for b=1:row
if data(b,1)==a ||data(b,2)==a
Y(a,a)=(Y(a,a)+data(b,8));
end
end
end
Ybus=Y

Risposte (1)

Guillaume
Guillaume il 2 Ott 2019
I don't know what else you expect from your code. You purposefully create an array data with 4 columns and then write:
.. = 1/(data(m,7)+data(m,8))
which sums columns 7 and 8 of an array with only 4 columns.
The error message is correct. Either create an array with enough columns or don't index inexistant columns.

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by