"Index exceeds matrix dimensions."

2 ビュー (過去 30 日間)
Eduardo Rojas
Eduardo Rojas 2019 年 8 月 18 日
コメント済み: Eduardo Rojas 2019 年 8 月 20 日
clear all
clc
nodos=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);
end
for 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);
end
clc
ybus
  3 件のコメント
Eduardo Rojas
Eduardo Rojas 2019 年 8 月 18 日
編集済み: per isakson 2019 年 8 月 18 日
The full message is: Index exceeds matrix dimensions.
Assignment has more non-singleton rhs dimensions than
non-singleton subscripts
Code:
clear all
clc
nodos=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);
end
for 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);
end
clc
ybus
Walter Roberson
Walter Roberson 2019 年 8 月 18 日
What line is the error being shown for?
What are the inputs you are using?
You should post enough that we can reproduce the problem on our systems.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2019 年 8 月 18 日
Ztramo is an fi by co by noZ matrix.
inv(Ztramo(:,:,i)) is a fi by co matrix if it works at all, which can only happen if fi and co are equal. Therefore
Ytramo(:,:,i)=inv(Ztramo(:,:,i));
makes Ytramo as a fi by co by noZ matrix.
Then in
k1=ne(i);
k2=nr(i);
k1 and k2 are scalars because i is a scalar and indexing by a scalar always gives a scalar.
ybus(k1,k1)=ybus(k1,k1)+Ytramo(:,:,i);
So the left hand size, ybus(k1,k1) is a scalar, and the right hand side of the equation needs to be a scalar. Looking at it, the ybus(k1,k1) part of the addition is a scalar, but Ytramo(:,:,i) we have determined must be fi by co . Adding a scalar to a matrix that is fi by co gives a matrix that is fi by co. Therefore the result of the addition is a matrix that is fi by co, and that is too big to store into the scalar area designated by the left side, ybus(k1,k1)
  3 件のコメント
Walter Roberson
Walter Roberson 2019 年 8 月 19 日
fi=2%('Número de filas de la matriz = ');
co=2%2'Número de columnas de la matriz = ');
You create a matrix which has fi rows and co columns.
Eduardo Rojas
Eduardo Rojas 2019 年 8 月 20 日
Ok, thank you
I'm working on the solution

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by