필터 지우기
필터 지우기

How to create an array that picks every 3 numbers out of 5

조회 수: 3 (최근 30일)
Derek Cooper
Derek Cooper 2020년 1월 30일
답변: Mohammad Sami 2020년 1월 30일
Hello,
I have a vector that includes degrees of freedom (numbers) from 1 to 665 and i want a function that makes an array to pick every 3 last numbers out of every numbers as a colomn and next colomn with zeros.
To make it more clear:
from 1 to 5 i want 3 4 5, then from 6 to 10, i want 8 9 10 and so on until 665. see below
C=[3 0;
4 0;
5 0;
8 0;
9 0;
10 0];

답변 (1개)

Mohammad Sami
Mohammad Sami 2020년 1월 30일
a = reshape(1:665,5,[]);
a(1:2,:) = [];
a = reshape(a,[],1);
a(:,2) = 0;

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by