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
2020년 5월 31일
y = [x, zeros(1, 92e2 - 74e2)]
댓글 수: 5
reto panda
2020년 5월 31일
madhan ravi
2020년 5월 31일
it depends what does "between" mean
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
2020년 5월 31일
madhan ravi
2020년 5월 31일
Huh? Post your answer.
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!