if we use the instruction [~, idx]=sort(abs(A(:))), what is this ~ (NOT) sign represents

3 ビュー (過去 30 日間)
studentambitious
studentambitious 2016 年 4 月 27 日
編集済み: Stephen23 2016 年 4 月 27 日
Can we replace ~ with any other name
  1 件のコメント
Stephen23
Stephen23 2016 年 4 月 27 日
編集済み: Stephen23 2016 年 4 月 27 日
The use of the tilde is explained in the documentation, and discussed in the MATLAB blogs:
Ambitious students should learn how to search for information themselves: they will find that their favorite internet search engine is a good place to start.

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

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 27 日
編集済み: Azzi Abdelmalek 2016 年 4 月 27 日
[e, idx]=sort([2 1 5 8 6])
will return
e= [1 2 5 6 8]
idx=[2 1 3 5 4]
[~, idx]=sort([2 1 5 8 6]
will return just idx. In this case, ~ is not considered as "not" operator

Jan
Jan 2016 年 4 月 27 日
For backward compatibiliy I do not use the tilde ~, but a variable called "dummy".
  2 件のコメント
Stephen23
Stephen23 2016 年 4 月 27 日
Do you use a pre-R2009b version?
Jan
Jan 2016 年 4 月 27 日
Beside 2015b I'm still using R6.5 and R2009a. While avoiding the tilde is trivial, catch exception required an ugly workaround for R6.5: catch ME_, ME = ME_. And under the historical Matlab a folder is included in the path, which defines the funktion ME_:
function Exception = ME_
persistent LastException
if nargout == 0
LastException = lasterror();
LastException.cause = {};
end
Exception = LastException;
I've backported the standard algebraic methods for single's, typecast, cast, uigetfiles, ancestor, commandwindow, javacomponent, javaObjectEDT.
The reason to maintain such an old system like R6.5 is an extremely well tested large code (>300'000 lines + comments) for clinical decision making and the need to guarantee the reproducibility of the results for 10 years. Fortunately the retirement of WindowsXP allows to skip R6.5 now :-) Bye bye, my beloved dinosaur.
Let me mention that R6.5 runs much faster in a VM with XP than 2015b on the real processor.

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

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by