8 digit double array to 1 digit double array

4 次查看(过去 30 天)
Hi, I am trying to extract 8 digit double array to 1 digit double array.
H = [10001000;
10000001]
I would like to save H(2*1) double matrix to
H_conv = [ 1 0 0 0 1 0 0 0;
1 0 0 0 0 0 0 1]
H_conv(2*8) double matrix.
Thank you.

采纳的回答

Walter Roberson
Walter Roberson 2020-4-15
编辑:Walter Roberson 2020-4-15
num2str(H) - '0'
This relies upon H being a column vector and will not give you the desired answer if H has more than one column.
It will also not give your desired answer if the top digit of H is not set in all values.
  4 个评论
Walter Roberson
Walter Roberson 2020-4-16
And you need the same number of digits in each number. It is a "fast and dirty" answer, not the best answer.

请先登录,再进行评论。

更多回答(2 个)

Tommy
Tommy 2020-4-15
How about
H_conv = num2str(H)-'0'

James Tursa
James Tursa 2020-4-15
For column vector H:
H_conv = cell2mat(arrayfun(@(x)sprintf('%08d',x),H,'uni',false)) - '0'

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by