Index exceeds matrix dimensions.
Ältere Kommentare anzeigen
function [L]=LineData
% ---------------------------------data input------------------------------
%{
Transmission line parameters:
1st & 2nd column for line "From-To"
From | To | R | X | Bsh
%}
L =[1 2 0.1 0.2 0.02
1 4 0.05 0.2 0.02
1 5 0.08 0.3 0.03
2 3 0.05 0.25 0.03
2 4 0.05 0.1 0.01
2 5 0.1 0.3 0.02
2 6 0.07 0.2 0.025
3 5 0.12 0.26 0.025
3 6 0.02 0.1 0.01
4 5 0.2 0.4 0.04
5 6 0.1 0.3 0.03]
end
function [B]=BusData
% ---------------------------------data input------------------------------
%bus number| Bus type | voltage schedule | Pgen | Pload | Qload
syms Swing
syms Gen
syms Load
syms Pg
syms Pl
syms Ql
B =[1 Swing 1.05 Pg Pl Ql
2 Gen 1.05 0.5 0 0
3 Gen 1.07 0.6 0 0
4 Load 0 0 0.7 0.7
5 Load 0 0 0.7 0.7
6 Load 0 0 0.7 0.7]
end
%%different file
L=LineData;
%Load BusData input Here:
B=BusData;
%Transmission line parameters:
ln = L(:,1);
rn = L(:,2);
R = L(:,3);
X = L(:,4);
%Bc = L(:,5);
%Bus parameters:
bn = B(:,1);
bt = B(:,2);
vs = B(:,3);
Pgen = B(:,4);
Pload = B(:,5);
Qload = B(:,6);
%Number of Buses:
Nb = max(max(ln), max(rn));
mat= [
1.4286 5.0000 0 5.0000 3.3333 0
5.0000 0.9524 4.0000 10.0000 3.3333 5.0000
0 4.0000 1.6393 0 3.8462 10.0000
5.0000 10.0000 0 1.4286 2.5000 0
3.3333 3.3333 3.8462 2.5000 0.6410 3.3333
0 5.0000 10.0000 0 3.3333 1.6667]
Bs=inv(mat)
syms Swing
syms Gen
syms Load
syms Pg
n = find(ismember(bt, Swing));
Bs(n,:) = []
Bs(:,n) = []
v = find(ismember(bt, Gen));
f = find(ismember(bt, Load));
P = zeros(Nb,1)
P= -Pload + Pgen
P(n,:)=[]
Q=Bs*P
sum(P)==Pg
for i = ln , j = rn
Pt(i,j)=(Q(i)-Q(j))/X(i,j); %Transmission power
end
first can i make this code simple and short?
second why am i getting this error?did i miss something?
and Q depends on Busdata so if first or second or...bt=swing Q of that row is zero
1 Kommentar
arian hoseini
am 10 Jan. 2022
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Code Performance finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


