array element concatenation, blank remove

2 views (last 30 days)
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

Accepted Answer

Awais Saeed
Awais Saeed on 13 Aug 2021
p=[1,0,0,0,0,0,1,0];
p = sprintf('%u',p); % it is a char
p = str2num(p); % converted to double
  1 Comment
Awais Saeed
Awais Saeed on 13 Aug 2021
an alternate
p=[1,0,0,0,0,0,1,0];
p = erase(num2str(p),' '); % it is a char
p = str2num(p);

Sign in to comment.

More Answers (1)

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

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!