Asked by Hajem Daham
on 8 Dec 2018

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.

Opportunities for recent engineering grads.

Apply Today
## 4 Comments

## Jan (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/434650-how-to-apply-a-condition-on-array#comment_648152

## Image Analyst (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/434650-how-to-apply-a-condition-on-array#comment_648208

## Hajem Daham (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/434650-how-to-apply-a-condition-on-array#comment_648218

## Hajem Daham (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/434650-how-to-apply-a-condition-on-array#comment_648222

Sign in to comment.