フィルターのクリア

Attaching a specific value to a set of numbers

4 ビュー (過去 30 日間)
Ahsan Khan
Ahsan Khan 2014 年 4 月 29 日
コメント済み: Ahsan Khan 2014 年 4 月 29 日
hi there, Say I have an array that consist of integer numbers 1 to 15. x = [1;3;5;6;15;9;8;10;11;13;12;14;7;2]. Notice that they are not in order. i want to attach a specific value to a set of numbers in the array. ex: if values 1,2,6,7,8 occur i want this value to be replaced with 1 if value 3,5,9,11,13 occur i want this value to be replaced with 2. the left over with a value 3.
I know of one way to do this. I can set an if statement for each value 1to15 but that's just not productive. is there a way i can set up a case statement maybe. any help would be appreciated. thank you. regards, SN
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 29 日
This is not clear

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

採用された回答

Niklas Nylén
Niklas Nylén 2014 年 4 月 29 日
編集済み: Niklas Nylén 2014 年 4 月 29 日
x(ismember(x,[1 2 6 7 8]))=1
  1 件のコメント
Ahsan Khan
Ahsan Khan 2014 年 4 月 29 日
thank you so much for a fast solution and a super fast reply. cheers

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by