Create char Cell Array with same string, multiple times

조회 수: 11 (최근 30일)
Jeongsoo Bae
Jeongsoo Bae 2018년 2월 15일
답변: Jeongsoo Bae 2018년 2월 15일
Hello,
I would like to write matlab command/code to make the program produce a char cell array, like,
'A'
'A'
'A'
'A'
'A'
'B'
'B'
.
.
.
and so on
but since I'm handling with few millions of dataset, I eagerly want to make the matlab do the job itself. The bottom is the command I tried, but there was no luck in middle way.
v=char( zeros(size(simpledata,1) + size(complexdata,1) , 1) ); %Create empty CHAR array, in total length of 2 LONG data -WAS OK
v(1:size(simpledata,1)) = "A" ; %This is where I stopped
  댓글 수: 2
James Tursa
James Tursa 2018년 2월 15일
편집: James Tursa 2018년 2월 15일
Your question is unclear. You are using the single quotes ' ' to indicate char class, and also using the double quotes " " to indicate string class, and then your title and text mention cell array. So what is it exactly that you want? A cell array of char strings, a cell array of string class variables, a string array, a char matrix, or what? How are you going to use this downstream in your code?
Jeongsoo Bae
Jeongsoo Bae 2018년 2월 15일
I mixed the things up :p Sorry about it! I am now trying to make this to be used in boxplot, as a grouping variable that lets boxplot know where the values should belong to.
As the attached picture says, I would like to generate Origin Char array, all at once.

댓글을 달려면 로그인하십시오.

채택된 답변

Jeongsoo Bae
Jeongsoo Bae 2018년 2월 15일
Guys, I actually found a way to do this in different way, using cell array, and also using repmat function. Thanks!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by