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

6 Ansichten (letzte 30 Tage)
Rengin
Rengin am 4 Mai 2019
Kommentiert: Rengin am 4 Mai 2019
% 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)?
% Thanks in advance!

Akzeptierte Antwort

Stephen23
Stephen23 am 4 Mai 2019
Bearbeitet: Stephen23 am 4 Mai 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

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by