how to creat if loop?
Mostrar comentarios más antiguos
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
%-----------------------------------------------------program strat here-------------------------------------------------------------
%Bus parameters:
bn = B(:,1);
bt = B(:,2);
vs = B(:,3);
Pgen = B(:,4);
Pload = B(:,5);
Qload = B(:,6);
mat %mat is 6*6 matrix
E=inv(mat)
%[P1;P2;...;Pn-1]=C
%[q1;1q2;...;qn-1]=D
C=E*D
syms Swing
for i=1:bn
if bt==Swing
E(i,:) = [];
E(:,i) = [];
end
end
disp(E)
and i want to do this for C & D and by the way n depends on which row of B is Swing(so if bn=2 is Swing then delete second row and second column if nb=1 is swing delete first row and column of mtarix E if... ) but i want this code to be general and i have tried many things but still confused and not getting my ans...
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Code Performance en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
