0

I have a 10,000 x 65 Cell with 0's and 1's so for example if I type

C(1,1) I get [0] returned or likewise C(3,4) a [1] is returned

I need a way to turn every 0 into a blank cell and every 1 into a char t

I've tried the following with little success

[rows, cols] = size(M); for i = 1:rows for j = 1:cols if strcmp(M(i,j), 1) M(i,j) = 't'; end end end

It returns the same thing, I'm guessing its not recognising the 1's as strings. Any idea sort of simply doing the conversion straight in Excel. thanks

1
  • 1
    If you think the problem is that it's not recognizing them as string then did you try if M(i,j)==1? Commented Oct 21, 2014 at 11:55

1 Answer 1

1

You are not accessing the cell data-structure correctly.

First of all, if M really is a cell array, you will have to use M{i,j} to access the data. What M(i,j)does is just create a sub-cell-array, which contains M{i,j} as entry.

Also strcmp isn't used correctly, if your cell array contains strings you should use strcmp(M{i,j}, '1'). If your cell array on the other hand contains integers, you would have to use: M{i,j}==1.

Sign up to request clarification or add additional context in comments.

Comments

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.