How to convert members of a matrix in a specific constrains value in MATLAB? -
if
a = 1 2 3 3.5 5 6 6.25 8 9 9.75 11 12 13 14 15
how possible switch numbers in specific constrains, smaller part of constrain?
in other word, if b=min(a)
& c=b+threshold
b<a<c
=> a=b
.
it means, in example, let's assume threshold=3. "a"
should alter matrix min(a):min(a)+threshold =[min(a)]
. procedure should go on lastly array of "a"
matrix adding each time amount of threshold. result should this:
a= 1 1 1 1 5 5 5 5 9 9 9 9 13 13 13
i guess found solution that. sorry if couldn't explain improve intention , mislead you. here code:
a = [1 2 3 3.5 5 6 6.25 8 9 9.75 11 12 13 14 15]'; b = min(a); threshold=4; c=b; i=1:size(a,1) c =c+threshold; a((a > b & < c)) = b; b=b+threshold; if c==max(a); break end end
p.s. threshold alter "threshold=4"
instead of "3"
matlab matrix constraints
No comments:
Post a Comment