フィルターのクリア

how to reverse "grp2idx" back into original data

4 ビュー (過去 30 日間)
Zeyad Elreedy
Zeyad Elreedy 2023 年 3 月 13 日
コメント済み: Zeyad Elreedy 2023 年 3 月 15 日
Hello, I have a categorical array of three categories: "S", "C", and "Q". I did "grp2idx()" in order to label each one of them (1,2,3) in order to do some operation, after which the new data (represented in 1,2,3) is different from the original one. I would now like to reverse the encoded vector back to a string vector. Is there any way to do so?

採用された回答

Raghvi
Raghvi 2023 年 3 月 14 日
編集済み: Raghvi 2023 年 3 月 14 日
Hey Zeyad,
I am assuming your string vector was s. To get an index vector you would have run.
[g,gN,gL] = grp2idx(s);
You can reproduce input argument s using the output gL:
gL(g(:,:))
You can also use gN(g) to reproduce the input argument s as a cell array of character vectors.
gN(g(:,:))
Checkout the examples in the documentation to know more about the conversions
  1 件のコメント
Zeyad Elreedy
Zeyad Elreedy 2023 年 3 月 15 日
Oh, it works now. Thanks!

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by