data encryption embedding in vector

Let the
big matrix= [15 0 -50 23 0 0 75]
small matrix=[1 0 1]
required matrix=[15 1 -50 23 0 1 75]
retaining all other values as it is

3 Comments

Please explain with a small example..
say Big Matrix = [1.5, 3.5, 0, -6, 1.3]
Small Matrix = [0, 1, 1]
What would your output be?
dpb
dpb on 21 Mar 2017
Edited: dpb on 21 Mar 2017
Put the question itself in the space for it with a short title in the title box...as the other respondent says, an minimal example illustrating what you mean, precisely, would be helpful.
let the big matrix= [15 0 -50 23 0 0 75] small matrix=[1 0 1] required matrix=[15 1 -50 23 0 1 75]

Sign in to comment.

 Accepted Answer

dpb
dpb on 21 Mar 2017
Edited: dpb on 21 Mar 2017
Taking a guess, without any error checking (there would have to be a minimum of length(shorter) zero elements in the longer array to avoid an error) assuming that "encrypt the 1,0 of smaller into only in zero values of larger" means to put the values of the shorter array into the zero locations of the larger in series, that's pretty trivial--
N=numel(short); % number in shorter
ix=long(ix==0); % logical array of zero loc's in longer array
long(ix(1:N))=short; % put that many elements into long at zero loc's
Perturbations of the above depending upon what other specific readings one makes of the request.
ADDENDUM
Well, the crystal ball was working this morning after all...
>> bigm=[15 0 -50 23 0 0 75];
smallm=[1 0 1];
>> bigm(bigm==0)=smallm
bigm =
15 1 -50 23 0 1 75
>>
NB: Above IFF
length(smallm)==sum(bigm==0)
otherwise need the previous length tests/truncation/whatever for error handling.

More Answers (0)

Categories

Asked:

on 21 Mar 2017

Edited:

dpb
on 22 Mar 2017

Community Treasure Hunt

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

Start Hunting!