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 件のコメント

ES
ES 2017 年 3 月 21 日
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 2017 年 3 月 21 日
編集済み: dpb 2017 年 3 月 21 日
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 2017 年 3 月 21 日
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]

サインインしてコメントする。

 採用された回答

dpb
dpb 2017 年 3 月 21 日
編集済み: dpb 2017 年 3 月 21 日

0 投票

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.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEncryption / Cryptography についてさらに検索

質問済み:

2017 年 3 月 21 日

編集済み:

dpb
2017 年 3 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by