Repeating elements in an array,accessing elements

2 views (last 30 days)
Question1: I have a resulting matrix from a gui as below: c =
Columns 1 through 6
'000011000' '001100111' '000111011' '001100100' '011000000' '001110001'
Columns 7 through 12
'010010011' '001000000' '011001000' '011000111' '011010011' '011001111'
Columns 13 through 16
'010001000' '000100000' '001010111' '011110001'
I am working in matlab R2013a version and I want each element of the above matrix to be repeated 3 times and the result be assigned to a new matrix D. (i.e if my matrix c was c=[111 101 100]; I want each element to repeat 3 times as D=[111 111 111 101 101 101 100 100 100])
I tried to use kron command and repelem command but both gives errors probably due to the version 2013a.Please help me with a code which will work in matlab R2013a The error is Undefined function 'times' for input arguments of type 'cell'.
Also I would like to know how to get c back once we have D.
Question 2:
When I have a matrix c as above when I type c(1,1) it gives the 1st element i.e 000011000. Is there a way to access each digit of the above element (like C(1,1)(1) , C(1,1)(2)...)?
Please help me with the above questions
Thanks a lot in advance.

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 28 Dec 2015
Edited: Azzi Abdelmalek on 28 Dec 2015
You need to use cell arrays
c={'111' '101' '100'}
d=repmat(c,3,1)
d=d(:)'
if you want to access any digit
d{2}(3)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!