How do I only keep specific values in an array of numbers?

22 ビュー (過去 30 日間)
Malin Dyberg
Malin Dyberg 2018 年 12 月 17 日
コメント済み: Malin Dyberg 2018 年 12 月 17 日
"krypt" is a text file which I want to convert to numbers, sort, and then only keep the characters that are letters (characters with number 65 to 90). Neither of the two examples below works. It works to put sort2=sort(sort~=32) but that only removes the blankspaces. There are a lot of other symbols that I dont want in "sort2" as well.
%"krypt" is a text file
sort=double(unique(krypt));
sort2=sort(sort==65:90);
%Or
sort2=any(sort(sort==65:90))

採用された回答

the cyclist
the cyclist 2018 年 12 月 17 日
編集済み: the cyclist 2018 年 12 月 17 日
You could do
intersect(yourArray,65:90)
You also should not use sort as a variable name, because it is a MATLAB keyword. You will quickly get confused and/or have an error when you later try to use the sort command.
  1 件のコメント
Malin Dyberg
Malin Dyberg 2018 年 12 月 17 日
Thank you so much, it works! And thanks for the tip :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by