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!
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).
Check out the getting started guide and especially this section: http://www.mathworks.co.uk/help/techdoc/learn_matlab/f2-8955.html
Demos are also useful: http://www.mathworks.co.uk/products/matlab/demos.html
0 Comments