Combining two matrices in the correct original order

1 次查看(过去 30 天)
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);

采纳的回答

David Hill
David Hill 2022-8-31
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.

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by