0

I have a cell array 1300x6 that is all numbers. Below is an example of one row:

| 000 | 00 | 00 | 12 | 345 | 678 |

What I want to accomplish, is to have all the numbers in each row concatenated into one cell so that it is a 1300x1 array. I have tried cat, vertcat, horzcat and reshape but they all just merge the columns into each other, creating more rows. I would like it to look like this:

| 000000012345678 |

Is this possible?

7
  • 2
    are they strings? do you want them to be strings? Commented Aug 3, 2017 at 10:50
  • They are cells or doubles, and I would like to be able to use them as an X axis in a plot. Commented Aug 3, 2017 at 10:53
  • 1
    cells AND doubles I hope you meant. They cant be though, they must be strings, as you can not have 000 and 00 as a number, they are both 0. Then you want them as a string? Commented Aug 3, 2017 at 11:06
  • 2
    Is this what you want: stackoverflow.com/questions/4868841/… ? Commented Aug 3, 2017 at 11:10
  • @AnderBiguri thanks I'll give it a go and let you know how I get on. Commented Aug 3, 2017 at 11:58

1 Answer 1

1

I agree with AnderBiguri that it is strange you would have 000 as a value in a numeric matrix, but you say it is all numbers, so let's go with that.

A = randi(255,[1300,6],'uint8'); %numbers
B = num2str(A); %characters with spaces
for ct = 1:size(B,1),C{ct,1}=strrep(B(ct,:),' ','');end 
C %characters without spaces
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks this is exactly what I wanted. Apologies for any lack of clarity in my question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.