How to initialize a cell with all zero values in matlab?

조회 수: 5 (최근 30일)
Roshni gupta
Roshni gupta 2017년 6월 16일
편집: Stephen23 2017년 6월 16일
I want a cell array charstring whose every cell is initialized with {000000}. I tried using
charstring={0 0 0 0 0 0 };
but its not working.

답변 (1개)

KSSV
KSSV 2017년 6월 16일
편집: KSSV 2017년 6월 16일
charstring={'0' '0' '0' '0' '0' '0'};
Or
charstring = [repmat({'0'},1,6)] ;
  댓글 수: 2
Stephen23
Stephen23 2017년 6월 16일
편집: Stephen23 2017년 6월 16일
@KSSV: you might want to think about this a bit more (or actually try it):
charstring = {[repmat('0',1,6]};
Perhaps you really meant to write:
charstring = repmat({'0'},1,6);
KSSV
KSSV 2017년 6월 16일
Yes..you are right.....edited the answer....

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

카테고리

Help CenterFile Exchange에서 Other Formats에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by