matlab if x<1 use x=1
Show older comments
Hello my questien i maby simple. But i vant an if funktion for a matrix.
my matrix could be like: A=[2 ; 0,6 ; 4 ; 0,9]
whant i vand to program is if A(i)<1 then A(i)=1 so the matrix should come out like: A=[2 ; 1 ; 4 ; 1]
3 Comments
Jan
on 13 Mar 2013
The matrix does not have valid Matlab syntax. Does "0,6" mean "0.6"? This details is important.
Claus Madsen
on 13 Mar 2013
Image Analyst
on 14 Mar 2013
So, is it solved yet? You haven't marked either answer as "Accepted". What problems are you still encountering?
Answers (2)
Cedric
on 13 Mar 2013
A(A<1) = 1
Image Analyst
on 13 Mar 2013
Here's another way to do it (though my first thought was Cedric's way):
A = max(A,1);
Categories
Find more on Mathematics 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!