Borrar filtros
Borrar filtros

One-to-one correspondence anonymous function

3 visualizaciones (últimos 30 días)
Arash
Arash el 10 de Feb. de 2013
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

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 10 de Feb. de 2013
Editada: Azzi Abdelmalek el 10 de Feb. de 2013
P=[10;100;105;700;700];
N=[5;8;4;11;20];
f=@(x) N(find(P==x));
f(700)
  2 comentarios
Walter Roberson
Walter Roberson el 11 de Feb. de 2013
The find() is not needed, P==x can be used directly.
Arash
Arash el 11 de Feb. de 2013
Editada: Arash el 11 de Feb. de 2013
Thank you Azzi, you helped a lot.

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 10 de Feb. de 2013
@(x) N(ismember(x, P))

Categorías

Más información sobre NaNs en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by