Replace certain values of matrix by one single value
Show older comments
Hi I'm relatively new to Matlab.. I would like to know how to generate a matrix B that replaces all components of a matrix A (which is a 100x100 randomly generated matrix) lying between 2.9 and 3.2, by -1. I also tried using the for loop but it wouldn't work.
for i=1:100;
j=1:100;
if A(i,j)==2.9:3.2;
A(i,j)=-1;
end
end
Thanks a lot!!!
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!