the meaning of "[~," in a matrix

41 Ansichten (letzte 30 Tage)
hamid
hamid am 25 Mär. 2016
Kommentiert: Star Strider am 23 Mär. 2023
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

Akzeptierte Antwort

Star Strider
Star Strider am 25 Mär. 2016
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 Kommentare
Allan
Allan am 23 Mär. 2023
Bearbeitet: Allan am 23 Mär. 2023
Thank You Mr.Star Strider (you are a goat)
Star Strider
Star Strider am 23 Mär. 2023
My pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by