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

조회 수: 4 (최근 30일)
Rengin
Rengin 2019년 5월 4일
댓글: Rengin 2019년 5월 4일
% 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!

채택된 답변

Stephen23
Stephen23 2019년 5월 4일
편집: Stephen23 2019년 5월 4일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by