Skip to main content
14-Alexandrite
October 8, 2023
Solved

Encontrar valor en columna en una matriz

  • October 8, 2023
  • 1 reply
  • 1262 views

Hola a todos, Soy nuevo en publicar aquí.

Como puedo encontrar el valor que le corresponde a un numero de una matriz (buscar) en una columna de una matriz X. en caso que el numero se repita varias veces se pueda poner el máximo y mínimo para ese numero.

Gracias de antemano por la atención prestada.

Matris.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

Best answer by Werner_E

¡Bienvenido al foro de Mathcad/Prime!

 

What you describe can be easily achieve using Primes various Lookup functions -> Lookup Functions

But what you picture shows sure is different would need some programming and also needs a more precise description of what you actually try to achieve.

As an example: Your vector Duscar contains twice the 4 and I see and assume that you want that the first and the last occurrence in the matrix X should be returned.

What should be returned if the 4 is present only once in Duscar?
What should be returned when the 4 is present three times in X?

 

In case you only inserted the two 3's and 4's and 11's because you "see" that these values occur multiple times and you are only interested in the first and last value, then it should not be necessary to do so - the program should automatically act accordingly if a values occurs multiple times in the first column of vector X.

 

Here is a first attempt:

Werner_E_1-1696792045774.png

 

Next time you should give it a try yourself, set up a worksheet and post it here!
You also should state which version of Prime you are using, because a file  made by a newer version cannot be read by an older one and there is no official way to convert it.

The attached file is in Prime 6 format, so I guess chances are high that you use a newer version and are able to open it.

 

EDIT: Added the try&catch to trap the error which would occur if the vector D contains a number not present in the first column of matrix X. Wrong numbers are simply skipped/ignored like the 6 I added in the vector D.

1 reply

Werner_E25-Diamond IAnswer
25-Diamond I
October 8, 2023

¡Bienvenido al foro de Mathcad/Prime!

 

What you describe can be easily achieve using Primes various Lookup functions -> Lookup Functions

But what you picture shows sure is different would need some programming and also needs a more precise description of what you actually try to achieve.

As an example: Your vector Duscar contains twice the 4 and I see and assume that you want that the first and the last occurrence in the matrix X should be returned.

What should be returned if the 4 is present only once in Duscar?
What should be returned when the 4 is present three times in X?

 

In case you only inserted the two 3's and 4's and 11's because you "see" that these values occur multiple times and you are only interested in the first and last value, then it should not be necessary to do so - the program should automatically act accordingly if a values occurs multiple times in the first column of vector X.

 

Here is a first attempt:

Werner_E_1-1696792045774.png

 

Next time you should give it a try yourself, set up a worksheet and post it here!
You also should state which version of Prime you are using, because a file  made by a newer version cannot be read by an older one and there is no official way to convert it.

The attached file is in Prime 6 format, so I guess chances are high that you use a newer version and are able to open it.

 

EDIT: Added the try&catch to trap the error which would occur if the vector D contains a number not present in the first column of matrix X. Wrong numbers are simply skipped/ignored like the 6 I added in the vector D.