Binary enabler for matrix

1 回表示 (過去 30 日間)
Serhat Unal
Serhat Unal 2022 年 6 月 6 日
コメント済み: Voss 2022 年 6 月 6 日
Hi Everyone,
I am quite confused and dont know how to enable or disable some variables in a matrix in matlab using the binary system.
My matrix looks like this: Inputs= [A B C D E F]; (the variables have double numbers in my case)
What I want to do is just to write lets say 1 1 1 0 1 1 to choose which ones I want to enable.
I want it to print Inputs=[A B C E F] and remove D from the matrix using binary system.
Does anyone know how to implement that in matlab ?
Preciate very much for help!
Regards,.

採用された回答

Voss
Voss 2022 年 6 月 6 日
Inputs = ["AA" "BB" "CC" "DD" "EE" "FF"];
to_enable = logical([1 1 1 0 1 1]);
Inputs(to_enable)
ans = 1×5 string array
"AA" "BB" "CC" "EE" "FF"
  2 件のコメント
Serhat Unal
Serhat Unal 2022 年 6 月 6 日
Thank you very much. That was exactly what I was searching for.
Voss
Voss 2022 年 6 月 6 日
Great! Any questions, let me know. Otherwise, please "Accept This Answer". Thanks!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by