Matrix Simple Index Question

1 visualización (últimos 30 días)
Steve
Steve el 1 de Jun. de 2012
Hello Experts,
1) Given matrix A with m rows and n columns, I want to check if there is an entry A(i,j)>alpha and if yes to make it A(i,j) = beta. How to make it without for and if? 2) How to make it in a vector of size (1,m) or (1,n)?
Thanks a lot in advance!

Respuesta aceptada

Oleg Komarov
Oleg Komarov el 1 de Jun. de 2012
Sample inputs:
m = 10;
n = 13;
A = rand(m,n);
alpha = .38;
Use logical indexing
idx = A > alpha;
A(idx) = 10;
Same applies to a vector (just play around with m and n to see that).
  4 comentarios
Oleg Komarov
Oleg Komarov el 1 de Jun. de 2012
Demos are also useful: http://www.mathworks.co.uk/products/matlab/demos.html
Steve
Steve el 2 de Jun. de 2012
Dear Oleg, again thank you very very much!!!
It was my great pleasure to get your answer and experts guide!
Steve

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by