Combining two matrices in the correct original order

1 Ansicht (letzte 30 Tage)
george masters
george masters am 31 Aug. 2022
Bearbeitet: Image Analyst am 1 Sep. 2022
I have one matrix of random intergers (x) which I have spilt into two matrices (A) and (B). I have then converted to binary, then manipulated it and I got back the original matrices A and B represented by r and rr.
How can I recombine the matrices r and rr to get back to the original matrix A?
close all; clc; clear all;
%% Generation
x=randi([1,128],128,128);
A=x(1:2:end,1:2:end,:);
a=de2bi(A,8).';
a=a(:);
Na=length(a);
B=x(2:2:end,2:2:end,:);
b=de2bi(B,8).';
b=b(:);
Nb=length(b);
%%% other processing %%%
%% get back original sqeuence
r=reshape(a,8,[])';
ss=bi2de(r)';
r=reshape(ss,64,64);
rr=reshape(b,8,[])';
s=bi2de(rr)';
rr=reshape(s,64,64);

Akzeptierte Antwort

David Hill
David Hill am 31 Aug. 2022
x=randi([1,128],128,128);%16,384 elements
A=x(1:2:end,1:2:end,:);%4,096 elements
B=x(2:2:end,2:2:end,:);%4,096 elements
Combining A and B will never give you back x.

Weitere Antworten (0)

Kategorien

Mehr zu Numeric Types finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by