## The usage of [~,I]=min(abs(A+B)) on a specific example

### Rengin (view profile)

on 4 May 2019
Latest activity Commented on by Rengin

on 4 May 2019

### Stephen Cobeldick (view profile)

% Dear Users,
% I have a curve whose axes are defined as below:
u=[1.01 1.02 1.03 1.11 1.13 1.04 0.84 0.86 0.97 0.97]; % y-axis
t=[1 2 3 4 5 6 7 8 9 10]; %x-axis
uref=1;
umin=uref*0.90;
umax=uref*1.10;
% t= 1, 2, 3, 6, 9 and 10 --> for let's say 6 seconds, the u values are within the limit (0.90 (umin)<=u<=1.10(umax))
% t= 4, 5, 7 and 8 --> for 4 seconds, the u values are out of the limit
% Using the function of [~,I]=min(abs(A+B)) or [~,I]=min(abs(A-B)), how can I calculate t_total=4 seconds (out of limit time)?

### Stephen Cobeldick (view profile)

on 4 May 2019
Edited by Stephen Cobeldick

### Stephen Cobeldick (view profile)

on 4 May 2019

I don't really see how min can help you. Basic logical indexing would be simpler, e.g.:
>> nnz(u<umin | u>umax)
ans = 4
Note you can get both values using one logical index:
>> idx = u<umin | u>umax;
>> nnz(idx)
ans = 4
>> nnz(~idx)
ans = 6

Rengin

### Rengin (view profile)

on 4 May 2019
Thanks it is very practical!