MATLAB Answers

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

1 view (last 30 days)
Derek Cooper
Derek Cooper on 30 Jan 2020
Answered: Mohammad Sami on 30 Jan 2020
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];

  0 Comments

Sign in to comment.

Answers (1)

Mohammad Sami
Mohammad Sami on 30 Jan 2020
a = reshape(1:665,5,[]);
a(1:2,:) = [];
a = reshape(a,[],1);
a(:,2) = 0;

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags

Products


Release

R2019b