Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Filling a vector of numbers using numbers from another vector

Subject: Filling a vector of numbers using numbers from another vector

From: Ulrik Nash

Date: 10 Jun, 2011 16:04:05

Message: 1 of 3

Hi Everyone,

Suppose that I have a vector A of unique numbers

A = [370 390 410 430]

Now I wish to create another vector B, which consists of the first number in A listed 4 times, the second number 4 times, and so forth for all numbers in A. 4 is chosen because of numel(A) = 4.

The result should look like this:

B = [370 370 370 370 390 390 390 390 410 410 410 410 430 430 430 430]

How could that be done?

Regards,

Ulrik.

Subject: Filling a vector of numbers using numbers from another vector

From: Jan Simon

Date: 10 Jun, 2011 16:27:04

Message: 2 of 3

Dear Ulrik,

  A = [370 390 410 430]
  B = repmat(A, numel(A), 1);
  B = reshape(B, 1, []);

Kind regards, Jan

Subject: Filling a vector of numbers using numbers from another vector

From: Ulrik Nash

Date: 10 Jun, 2011 17:04:04

Message: 3 of 3

"Jan Simon" wrote in message <istgko$eva$1@newscl01ah.mathworks.com>...
> Dear Ulrik,
>
> A = [370 390 410 430]
> B = repmat(A, numel(A), 1);
> B = reshape(B, 1, []);
>
> Kind regards, Jan

Thank you very much Jan.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us