how can i sum X's or R's values that their nl=1?

1 Ansicht (letzte 30 Tage)
arian hoseini
arian hoseini am 7 Jan. 2022
Bearbeitet: arian hoseini am 7 Jan. 2022
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]
nl = L(:,1); nr = L(:,2); R = L(:,3);
X = L(:,4); Bc = j*L(:,5);
nbr=length(linedata(:,1)); nbus = max(max(nl), max(nr));
i wanna sum X's whose nl = 1....(ans=0.2+0.2+0.3=0.7)

Akzeptierte Antwort

VIGNESH B S
VIGNESH B S am 7 Jan. 2022
Matlab actually takes every column as variables.
In the below shown example sum gives the result as follows ,Output is 2 4 6 8 10.
If you wish to find the sum (1+2+3+4+5) row wise in a n*m matrix -> JUST Trasnpose the matrix and find the sum.
x = [1,2,3,4,5;1,2,3,4,5];
sum(x)
Transpose = x'
sum(Transpose) %Output here is 15 15.
%If you just want sum of first column here assign the o/p to a variable
%and access the 1st element .. var(1) ->a11+a12+a13.. of matrix x.

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by