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:
produce a cell from multiple rows of a matrix

Subject: produce a cell from multiple rows of a matrix

From: Barry Shaw

Date: 29 May, 2012 10:16:07

Message: 1 of 2


Hi.

Wasn't quite sure what to put as subject title to explain this.....

I have two matrices, z and x, and I want to produce a cell (t) without using a loop.
>> z

z =

    10
    20
    30

>> x

x =

     9 11
    19 21
    29 31

>> t={'10 (9,11)';'20 (19,21)';'30 (29,31)'}

t =

    '10 (9,11)'
    '20 (19,21)'
    '30 (29,31)'

I've done this for 1 row as follows:
>> p=sprintf(' (%d,%d)', x(1,1),x(1,2))

p =

 (9,11)

>> pp={strcat(num2str( z(1)), p)}

pp =

    '10 (9,11)'

but I can't figure out how to do it for multiple rows of z and x without using a loop. In reality my z and x will have lots more than 3 rows.

Any suggestions?

Subject: produce a cell from multiple rows of a matrix

From: reza

Date: 29 May, 2012 21:06:12

Message: 2 of 2

On May 29, 6:16

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