필터 지우기
필터 지우기

One-to-one correspondence anonymous function

조회 수: 5 (최근 30일)
Arash
Arash 2013년 2월 10일
I was wondering if can make an injective (one-to-one correspondence) anonymous function to do this;
if the input was one member from P then function convert it to correspondence member in N, for example if input is x=10 out put will be y=5, x=105-->y=4 and ...
P=[10;100;105;700;943]
N=[5;8;4;11;20]
Thanks in advance, Arash

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 10일
편집: Azzi Abdelmalek 2013년 2월 10일
P=[10;100;105;700;700];
N=[5;8;4;11;20];
f=@(x) N(find(P==x));
f(700)
  댓글 수: 2
Walter Roberson
Walter Roberson 2013년 2월 11일
The find() is not needed, P==x can be used directly.
Arash
Arash 2013년 2월 11일
편집: Arash 2013년 2월 11일
Thank you Azzi, you helped a lot.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2013년 2월 10일
@(x) N(ismember(x, P))

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by