the meaning of "[~," in a matrix

39 ビュー (過去 30 日間)
hamid
hamid 2016 年 3 月 25 日
コメント済み: Star Strider 2023 年 3 月 23 日
Hi
my friend send to me a code that I don`t understand a line of it. The line is:
[~ , x_opt] = min(g); % g is the cost function vector
my question is that what is the meaning of "[~," in a matrix?
thanks

採用された回答

Star Strider
Star Strider 2016 年 3 月 25 日
The tilde ‘~’ in a function output tells MATLAB to not import that output in the calling function workspace. The min function can produce two outputs, the minimum (the first output) and the index of the first instance of the minimum value for the second. In the code you quoted, whoever wrote it was only interested in the index.
  6 件のコメント
Allan
Allan 2023 年 3 月 23 日
編集済み: Allan 2023 年 3 月 23 日
Thank You Mr.Star Strider (you are a goat)
Star Strider
Star Strider 2023 年 3 月 23 日
My pleasure!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by