how can i sum X's or R's values that their nl=1?
1 次查看(过去 30 天)
显示 更早的评论
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)
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!