array element concatenation, blank remove

조회 수: 1 (최근 30일)
dmfwlansejr
dmfwlansejr 2021년 8월 13일
댓글: Awais Saeed 2021년 8월 13일
p=[1,0,0,0,0,0,1,0]
p=
1 0 0 0 0 0 1 0
This is 1 row,1 colimn
I wnat to make
p=
10000010
, blank removed. This is 1 row, 1 colimn

채택된 답변

Awais Saeed
Awais Saeed 2021년 8월 13일
p=[1,0,0,0,0,0,1,0];
p = sprintf('%u',p); % it is a char
p = str2num(p); % converted to double
  댓글 수: 1
Awais Saeed
Awais Saeed 2021년 8월 13일
an alternate
p=[1,0,0,0,0,0,1,0];
p = erase(num2str(p),' '); % it is a char
p = str2num(p);

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

추가 답변 (1개)

Chunru
Chunru 2021년 8월 13일
p=[1,0,0,0,0,0,1,0];
n = length(p);
q = sum(p.*10.^(n-1:-1:0))
q = 10000010

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by