putting zero between sequence

I have "x" with length 7400 . I want to put zeros between this sequnce to get "y" with length 9200 . how can I do this?
x=[1:1:7400]

回答 (1 件)

madhan ravi
madhan ravi 2020 年 5 月 31 日

0 投票

y = [x, zeros(1, 92e2 - 74e2)]

5 件のコメント

reto panda
reto panda 2020 年 5 月 31 日
no I want zeros between x1 equivalently . not all zeros after sequence
madhan ravi
madhan ravi 2020 年 5 月 31 日
it depends what does "between" mean
madhan ravi
madhan ravi 2020 年 5 月 31 日
編集済み: madhan ravi 2020 年 5 月 31 日
x = 1:74e2;
pos1 = 3; % this should be within the number of x elements
pos2 = pos1-1+(92e2 - 74e2);
ix = pos1:pos2;
b = zeros(1,numel(ix)); % number of zeros
y = zeros(1,numel(x)+numel(b));
y(setdiff(1:numel(y),ix)) = x
size(y) % to check
reto panda
reto panda 2020 年 5 月 31 日
this is not true. zeros all are together in y.
but Ii found the answer myself
so thanks anyway
madhan ravi
madhan ravi 2020 年 5 月 31 日
Huh? Post your answer.

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

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2020 年 5 月 31 日

コメント済み:

2020 年 5 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by