how can we do this?
2 ビュー (過去 30 日間)
古いコメントを表示
i want to calculate the maximum of vectors éléments and its position using the diff command, can any one help me ?
2 件のコメント
John D'Errico
2018 年 11 月 29 日
Why not just use max? Since it does exactly what you claim to want.
diff as applied to a vector will not help you here.
採用された回答
madhan ravi
2018 年 11 月 29 日
[value,index]=max(vector) %use max which does exactly what you want
7 件のコメント
Jan
2018 年 12 月 3 日
編集済み: Jan
2018 年 12 月 3 日
@diadaline: Use these three inputs:
a = rand(1, 10)
b = 1:10
c = 10:-1:1
While using max() is easy here, there is no chance to use diff() to find a maximum value. But here, diff can be useful:
d = sin(0:0.001:pi)
Here you have the additional knowledge, that the elements are monotonically increasing and decreasing. Together with this knowledge diff can be used:
find(diff(d) <= 0, 1, 'first')
max() is more useful, because it works in the general case also.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Discrete Math についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!