Filter löschen
Filter löschen

I have two matrices and I want to take the minimum of them and then set the value in the minimum matrix to 0 if it comes from matrix A and 1 if it comes from matrix B. How do I do this?

33 Ansichten (letzte 30 Tage)
Hi all,
I have two matrices of random variable from specific distributions with specific parameters. Consider them matrix A and matrix B. I want to observe the minimum{A,B}. But I need to know from which matrix the minimum value came from and then, if it comes from matrix A, set it equal to 1 and if it comes from matrix B, set it equal to 0.
Essentially, I'm building a random vector of censored units. So I know that I want to find:
C = min(A,B) % which givens me a matrix that's the same size of A and B of the minimum value, element-wise between A and B.
But then, I need a way to code that if the element i in C comes from A, then for a new matrix of the same size, D, the ith element of D = 1. And if the ith element in C comes from B, then the ith element of D = 0.
Can anyone help me with this?
Thank you.

Akzeptierte Antwort

David Fletcher
David Fletcher am 29 Mär. 2018
C=min(a,b)
D=minC==a

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by