How to apply a condition on array?
1 view (last 30 days)
Show older comments
a = [1 2 3 4 5]
x(a) = [15 20 45 25 30]
b = [6 7 8 9 10]
x(b) = [20 25 30 15 15]
t=40
the below array ab is a random permutation of a and b elemnts and then zeros are inserted.
ab = 5 2 6 0 4 9 8 7 0 1 10 0 3
I want to apply this condition on the between zeros of array ab:
the condition is that if the values of the corresponding values of x(a) and x(b) for a and b elemnts between zeros are greater than t, in this case add a penalty of 100. Then acummulate the total penalty of these between zeros values
This condition includ the mix case of 1-5 and 6-10 between zeros and the individaul case like 3 at the end of ab.
4 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!