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 Center および File ExchangeLogical についてさらに検索

タグ

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by