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

조회 수: 1 (최근 30일)
arian hoseini
arian hoseini 2022년 1월 7일
편집: arian hoseini 2022년 1월 7일
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)

채택된 답변

VIGNESH B S
VIGNESH B S 2022년 1월 7일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by