condition on random generated data

1 visualización (últimos 30 días)
abdul rehman
abdul rehman el 13 de Jun. de 2021
Editada: Adam Danz el 14 de Jun. de 2021
abc_data = rand((randi(20)),2)
on the above random data, I want to put a condition that if row value 1 > 0.5 and column value 1> 0.6 than print true else false

Respuesta aceptada

Adam Danz
Adam Danz el 13 de Jun. de 2021
Editada: Adam Danz el 14 de Jun. de 2021
> if row value 1 > 0.5 and column value 1> 0.6 than print true else false
It sounds like you are only interested in assessing row 1 and column 1 which are vectors of two different lengths. If you want to do something different, please explain more clearly the goal.
abc_data = rand((randi(20)),2)
abc_data = 12×2
0.8582 0.4476 0.4260 0.6028 0.7803 0.1592 0.2553 0.5614 0.5697 0.3633 0.9326 0.7562 0.9734 0.7677 0.4696 0.7044 0.7278 0.8881 0.1457 0.4547
% For row 1
abc_data(1,:) > 0.5
ans = 1×2 logical array
1 0
% For col 1
abc_data(:,1) > 0.6
ans = 12×1 logical array
1 0 1 0 0 1 1 0 1 0
% For all rows (if any values are > 0.5)
any(abc_data > .5, 2)
ans = 12×1 logical array
1 1 1 1 1 1 1 1 1 0
% For all columns (if any values are greater > 0.6)
any(abc_data > .6, 1)
ans = 1×2 logical array
1 1

Más respuestas (0)

Categorías

Más información sobre Random Number Generation en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by