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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by