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 Center および File ExchangeData Types についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by