MATLAB Answers

0

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

Asked by Busra Uzum on 2 Oct 2019
Latest activity Answered by Guillaume
on 2 Oct 2019
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

  0 Comments

Sign in to comment.

1 Answer

Answer by Guillaume
on 2 Oct 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.

  0 Comments

Sign in to comment.