clear allclcnodos=input('Ingresa la cantidad de nodos del sistema\n n = ');noZ=input('Ingresa la cantidad de lineas del sistema \n NoZ = ');for i=1:noZ %Ciclo para ingresar los valores de la Z de rama.
ne(i)=input('Número de referencia del nodo emisor = '); nr(i)=input('Número de referencia del nodo receptor = '); %clc
fi=2%('Número de filas de la matriz = ');
co=2%2'Número de columnas de la matriz = ');
clc disp(['Ingresa la matriz de impedancias de la linea #',num2str(i),':']) for j=1:fi%Filas
for jj=1:co%Columnas
disp(['El elemento (',num2str(j),',',num2str(jj),')']) Ztramo(j,jj,i)=input(''); end end clc disp(['La matriz de impedancias del tramo #',num2str(i),' es:']) Ztramo% Muestra Z de tramo con ceros.
disp(['La matriz de admitancias del tramo #',num2str(i),' es:']) Ytramo(:,:,i)=inv(Ztramo(:,:,i)); Ytramo ybus=diag(0,(nodos*2)-1);endfor i=1:noZ %Ciclo para la formación de YBUS
k1=ne(:,:,i); k2=nr(:,:,i); ybus(k1,k1)=ybus(k1,k1)+Ytramo(:,:,i); ybus(k2,k2)=ybus(k2,k2)+Ytramo(:,:,i); ybus(k1,k2)=-Ytramo(:,:,i); ybus(k2,k1)=ybus(k1,k2);endclcybus
MATLAB: “Index exceeds matrix dimensions.”
arraydebug4mematrixmatrizybus
Best Answer