필터 지우기
필터 지우기

A method to control on a certain variable n is present in a column (left or right) of a matrix

조회 수: 1 (최근 30일)
Hi,
Someone could help me find a method to check on a certain variable n is present in a column (left or right) of a matrix.
The matrix presents with these dimensions:
Edge = [1 2;
2 3;
3 4;
2 6;
3 7;
5 6;
6 7;
7 8];
[i,j]=size(Edge);
Thank you so much!
  댓글 수: 2
Sriram Tadavarty
Sriram Tadavarty 2020년 4월 28일
For example, if you want to find value 1. Try,
[i,j] = find(Edge == 1);
Hope this helps.
Marco Camozzi
Marco Camozzi 2020년 4월 28일
Thanks a lot for the answer, I am looking for a function that certifies me if my variable n is present in the first left column, because the left column corresponds to all the starpoints of a grid of segments

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

채택된 답변

Tommy
Tommy 2020년 4월 28일
편집: Tommy 2020년 4월 28일
Possibly this?
>> any(Edge==2)
ans =
1×2 logical array
1 1 % 2 is present in both
>> any(Edge==1)
ans =
1×2 logical array
1 0 % 1 is present in first column
>> any(Edge==9)
ans =
1×2 logical array
0 0 % 9 is present in neither column
(edit) Then how about this?
any(Edge(:,1)==n)
For exampe,
>> any(Edge(:,1)==9)
ans =
logical
0
  댓글 수: 1
Marco Camozzi
Marco Camozzi 2020년 4월 28일
Thanks a lot for the answer, I am looking for a function that certifies me if my variable n is present in the first left column, because the left column corresponds to all the starpoints of a grid of segments

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by