Azzera filtri
Azzera filtri

Binary matrix, negative number display.

4 visualizzazioni (ultimi 30 giorni)
I want to express the subtraction of a binary matrix as a negative number.
ex) = 00000000 - 00001001 = 10001001
Below is the code that I tried.
num = (0:9)';
num_ver = repmat(num,[1,length(num)]);
num_hor = num_ver';
num_comb = [num_hor(:),num_ver(:)];
A = zeros(size(num_comb,1),8);
for ii = 1:length(num_comb)
str2 = dec2bin(-(num_comb(ii,:)),8);
str2_ = [str2;' '];
A(ii,:) = str2num(str2_(:)');
In the case of addition and multiplication, the desired value was output.(sum,prod)
The output value I want is as follows.
A=
[00000000;
10000001;
10000010;
10000011;
10000100;
10000101;
10000110;
10000111;
10001000;
10001001;
00000001;
00000000;
10000001;
10000010;
10000011;
10000100;
10000101;
10000110;
10000111;
10001000;
00000010;
00000001;
00000000;
10000001;
10000010;
10000011;
10000100;
10000101;
10000110;
10000111;
00000011;
00000010;
00000001;
00000000;
10000001;
10000010;
10000011;
10000100;
10000101;
10000110;
00000100;
00000011;
00000010;
00000001;
00000000;
10000001;
10000010;
10000011;
10000100;
10000101;
00000101;
00000100;
00000011;
00000010;
00000001;
00000000;
10000001;
10000010;
10000011;
10000100;
00000110;
00000101;
00000100;
00000011;
00000010;
00000001;
00000000;
10000001;
10000010;
10000011;
00000111;
00000110;
00000101;
00000100;
00000011;
00000010;
00000001;
00000000;
10000001;
10000010;
00001000;
00000111;
00000110;
00000101;
00000100;
00000011;
00000010;
00000001;
00000000;
10000001;
00001001;
00001000;
00000111;
00000110;
00000101;
00000100;
00000011;
00000010;
00000001;
00000000;
];

Risposta accettata

Image Analyst
Image Analyst il 8 Dic 2021
You'll have to have A be character array or a string array, not a numerical array.

Più risposte (0)

Categorie

Scopri di più su Multidimensional Arrays in Help Center e File Exchange

Tag

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by