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

Split array values into 2 elements

Asked by Praveen Nandakumar on 5 Dec 2012

A = [126126,138154,137146]

Output i want is A = [126,126,138,154,137,146]

2 Comments

José-Luis on 5 Dec 2012

Praveen, please accept answers if they help you. I have looked at your question history and you never seem to do that.

Praveen Nandakumar on 5 Dec 2012

hey i do accept...whn i find right answers... thank you

Praveen Nandakumar

Tags

Products

No products are associated with this question.

3 Answers

Answer by Jos (10584) on 5 Dec 2012
Edited by Jos (10584) on 5 Dec 2012
Accepted answer

help rem

help floor

A = [126126, 138154,137146]
B = [floor(A/1000) ; rem(A,1000)] 
B = B(:).' % for cosmetic purposes only

1 Comment

Praveen Nandakumar on 5 Dec 2012

its working.... thank you

Jos (10584)
Answer by Azzi Abdelmalek on 5 Dec 2012
Edited by Azzi Abdelmalek on 5 Dec 2012
out=str2num(reshape(num2str(A')',3,[])')'

1 Comment

Praveen Nandakumar on 5 Dec 2012

thank you... its working

Azzi Abdelmalek
Answer by Steve on 5 Dec 2012

The function you want is reshape:

A = reshape(A, 1, [])

This gives you the output you want (A = [126,126,138,154,137,146])

0 Comments

Steve

Contact us