필터 지우기
필터 지우기

Representation of matrix in term of sets

조회 수: 4 (최근 30일)
rohini more
rohini more 2022년 3월 22일
댓글: rohini more 2022년 3월 23일
Code:
n=3
A = eye(n);
idx = randperm(n);
A = A(idx, :)
for i=1:n
for j=1:n
if A(i,j)~=0 && A(i,i)~=1
k1=[i j]
end
end
end
Output:
I have attached pdf below please find the attachment.
Here I got, k1= 1 2 and k1=2 1
But I want
In set form
But I am getting in matrix form.
How to proceed please give me guideline.
Thanks in advance.

채택된 답변

Matt J
Matt J 2022년 3월 22일
편집: Matt J 2022년 3월 22일
Simpler:
d=diag(A);
A(d==1,:)=0;
[I,J]=find(A);
k=[I,J];
I don't know what you mean by "set form". If you want each pair as the element of cell array, simply do
k=num2cell(k,2)
  댓글 수: 6
rohini more
rohini more 2022년 3월 22일
Okay.
Thank you for your suggestion.
Really thanks a lot for your valuable time.
rohini more
rohini more 2022년 3월 23일
After applying below command I am getting error which is mentioned in the pdf. Please find the attachment
all(ismember(k1,k2,'rows'))
Please give me suggestion to get rid of this error
Thanks a lot for investing your valuable time on this query and also for valuable suggestion.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by