cellをcategaricalに変更する方法

8 views (last 30 days)
HY
HY on 21 Dec 2021
Commented: HY on 22 Dec 2021
 
質問失礼いたします。
左の画像にあるように1行1列のラベルだけを、右の画像の1行1列のラベルに変換させたいのですが、
単純に下記のようなコードを実行すると、エラーが発生してしまいます。
labels{1,1} = label{1,1};
非セル配列オブジェクトにセル要素を代入しています。
cell配列をcategoricalに変換させてから代入したいのですが、どのように対処すればわかりません。
ご回答よろしくお願いいたします。

Accepted Answer

Kojiro Saito
Kojiro Saito on 22 Dec 2021
「非セル配列オブジェクトにセル要素を代入しています。」のエラーは、labels{1,1}のところで起きています。
中括弧{}で要素にアクセスするのはセル配列だけできるのですが、labelsは2x1のcategorical配列で、セルにはなっていません。labels{}をlabels()と小括弧に変えるだけでやりたいことが実現できます。
labels(1,1) = label{1,1};
  1 Comment
HY
HY on 22 Dec 2021
ご回答ありがとうございます。
解決できました。
ありがとうございます。

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!