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 Kommentare

ES
ES am 21 Mär. 2017
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 am 21 Mär. 2017
Bearbeitet: dpb am 21 Mär. 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.
Jatin chinchkar
Jatin chinchkar am 21 Mär. 2017
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]

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

dpb
dpb am 21 Mär. 2017
Bearbeitet: dpb am 21 Mär. 2017

0 Stimmen

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.

Weitere Antworten (0)

Kategorien

Mehr zu Encryption / Cryptography finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 21 Mär. 2017

Bearbeitet:

dpb
am 22 Mär. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by