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

7 ビュー (過去 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
  1 件のコメント
Rengin
Rengin 2019 年 5 月 4 日
Thanks it is very practical!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by