フィルターのクリア

How to build a vector in MATLAB

1 回表示 (過去 30 日間)
charu shree
charu shree 2023 年 3 月 25 日
コメント済み: charu shree 2023 年 3 月 25 日
Hello all, I am trying to build a vector of size 404 by 1 which is a vector of labels.
I had made the following code:
Labels = 16; r = 6;
C1 = 1:Labels;
C_labels_train = (repelem(C1,r))';
C_labels_test = [C_labels_train; C_labels_train; C_labels_train; C_labels_train ];
Here C_labels_train consists of labels of training data and I want to give such labels to test data as well.
So, my query is that C_labels_test (which are the labels of test data) has dimension of 384 by 1. So how to obtain the vector of 404 by 1 dimension ?
Any help in this regard will be highly appreciated.

採用された回答

VBBV
VBBV 2023 年 3 月 25 日
Labels = 16; r = 6;
C1 = 1:Labels
C1 = 1×16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
C_labels_train = (repelem(C1,r))'
C_labels_train = 96×1
1 1 1 1 1 1 2 2 2 2
C_labels_test = [C_labels_train; C_labels_train; C_labels_train; C_labels_train; C_labels_train(1:20) ];
C_labels_test = 404×1
1 1 1 1 1 1 2 2 2 2
  2 件のコメント
VBBV
VBBV 2023 年 3 月 25 日
one option is add the array
% add 20 elements of C_labels_train vector
C_labels_train(1:20) % since the final vector length you want is 404 x 1
to the final vector
C_labels_test = [C_labels_train; C_labels_train; C_labels_train; C_labels_train; C_labels_train(1:20) ];
charu shree
charu shree 2023 年 3 月 25 日
Thank you so much sir....

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by