WHY THIS ERROR OCCUR ''??? Subscript indices must either be real positive integers or logicals."" IN 14TH LINE OF MY PROGRAM.PLEASE HELP ME .....THANKING YOU
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
clear all;
zdata=[1 2 .025 .1;2 3 .02 .08;3 4 .05 .2;1 4 .04 .16];
n1=zdata(:,1);
nr=zdata(:,2);
r=zdata(:,3);
x=zdata(:,4);
nbr=length(zdata(:,1));
nbus=max(max(n1),max(nr));
z=r+1j*x;
y=ones(nbr,1)./z;
ybus=zeros(nbus,nbus);
for k=1:nbr
if n1(k)>0&&nr(k)>0
ybus(n1(k),nr(k))=ybus(n1(k),nr(k)-y(k));
ybus(nr(k),n1(k))=ybus(n1(k),nr(k));
end
end
for n=1:nbus
for k=1:nbr
if n1(k)==n||nr(k)==n
ybus(n,n)=ybus(n,n)+y(k);
else
end
end
end
ybus
0 comentarios
Respuestas (3)
Arthur
el 5 de Nov. de 2012
You are trying to retrieve values from ybus using n1 and nr, which are derived from zdata. However, zdata contains values that are not integers. For instance, ybus(.025, 0.2) cannot exist, subscripts have to be integers.
I'm not sure what you are trying to do in this code, but with these values of zdata it will not work.
2 comentarios
Arthur
el 5 de Nov. de 2012
I don't know what a zbus is. But for your code to run, zdata must contain only integers.
Quynh tran
el 2 de Abr. de 2016
clear all;
zdata=[1 2 .025 .1;2 3 .02 .08;3 4 .05 .2;1 4 .04 .16];
n1=zdata(:,1);
nr=zdata(:,2);
r=zdata(:,3);
x=zdata(:,4);
nbr=length(zdata(:,1));
nbus=max(max(n1),max(nr));
z=r+1j*x;
y=ones(nbr,1)./z;
ybus=zeros(nbus,nbus);
for k=1:nbr
if n1(k)>0&&nr(k)>0
ybus(n1(k),nr(k))=ybus(n1(k),nr(k)-y(k));
ybus(nr(k),n1(k))=ybus(n1(k),nr(k));
end
end
for n=1:nbus
for k=1:nbr
if n1(k)==n
ybus(n,n)=ybus(n,n)+y(k);
else
if nr(k)==n
ybus(n,n)=ybus(n,n)+y(k); %this row I think should be another formulation
end
end
end
end
Walter Roberson
el 2 de Abr. de 2016
zdata=[1 2 .025 .1;2 3 .02 .08;3 4 .05 .2;1 4 .04 .16];
n1=zdata(:,1);
nr=zdata(:,2);
Those lines are fine in themselves. n1 and nr both get assigned values that are strictly non-negative integers, so it is fine to use elements of n1 and nr as indices.
r=zdata(:,3);
x=zdata(:,4);
z=r+1j*x;
Those extract non-integral values, and create z as a vector of complex non-integral numbers.
y=ones(nbr,1)./z;
So y is going to be the reciprocal of complex numbers, and so is going to be complex itself.
ybus(n1(k),nr(k))=ybus(n1(k),nr(k)-y(k));
Here on the right hand side, ybus is being indexed by n1(k) and nr(k)-y(k) . The first of those, n1(k), we have shown will be a positive integer, so that first subscript is fine. The second of those, nr(k)-y(k), we have shown that nr(k) will be an integer but that y(k) will be a complex non-integral value. We can see that nr(k)-y(k) must be a complex result. complex results cannot be used as indices for arrays.
I speculate that the desired line was
ybus(n1(k),nr(k)) = ybus(n1(k),nr(k)) - y(k);
Here, the n1 and nr are both positive integers and can be used as indices. The ybus value is indexed and retrieved and the complex value y(k) is subtracted from that, which is completely valid because the complex value is not being used as an index.
0 comentarios
Ver también
Categorías
Más información sobre Engines & Motors en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!