in the following MATLAB Programme, I want print the resultant Matrix D with two conditions i) D has exactly one Zero ii) D with exactly two pairs like as (-x, x) and (-y, y)
2 次查看(过去 30 天)
显示 更早的评论
A = [0 1 0 0 1 ; 1 0 1 0 0 ; 0 1 0 1 0 ; 0 0 1 0 1 ; 1 0 0 1 0]
B = [-1 -2 1 2 0];
C = perms (B);
E=C
D=C*A
0 个评论
采纳的回答
Arif Hoq
2022-2-22
编辑:Arif Hoq
2022-2-22
A = [0 1 0 0 1 ; 1 0 1 0 0 ; 0 1 0 1 0 ; 0 0 1 0 1 ; 1 0 0 1 0];
B = [-1 -2 1 2 0];
C = perms (B);
D=C*A;
[Lia, Locb] = ismember(C,D, 'rows');
samerow=unique(Locb); % this row of D satifies the 2 condition
samerow(1)=[]; % delete the first 0 value
% rownumber=samerow(2:end);
output=D(samerow,:)
6 个评论
Arif Hoq
2022-2-27
if you change variable A you can get the output
A = [0 2 0 0 2 ; 1 0 1 0 0 ; 0 1 0 1 0 ; 0 0 1 0 1 ; 1 0 0 1 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!