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 A with all numbers from B starting at specific place in A

Subject: Filling a vector A with all numbers from B starting at specific place in A

From: Ulrik Nash

Date: 5 Jul, 2011 10:32:10

Message: 1 of 2

Hi Everyone,

Suppose I have a vector B with data and that B has 10 rows.

Suppose also I have an empty vector A with 20 row

Now I wish to insert the data in B into A starting at column 11 in A

So, the following won't work A(:,1) = B

since this assumes that data should be inserted starting a place 1.

So, how can I go about this?

Regards,

Ulrik.

Subject: Filling a vector A with all numbers from B starting at specific

From: Jomar Bueyes

Date: 5 Jul, 2011 12:10:45

Message: 2 of 2

On Jul 5, 6:32 am, "Ulrik Nash" <u...@sam.sdu.dk> wrote:
> Hi Everyone,
>
> Suppose I have a vector B with data and that B has 10 rows.
>
> Suppose also I have an empty vector A with 20 row
>
> Now I wish to insert the data in B into A starting at column 11 in A
>
> So, the following won't work A(:,1) = B
>
> since this assumes that data should be inserted starting a place 1.
>
> So, how can I go about this?
>
> Regards,
>
> Ulrik.

You want to assign B to columns 11 to 20 of A, so index those columns:

A(:,11:20) = B;

This assumes that A already exists and has the same number of rows as
B.

HTH

Jomar

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