2

My sentiment variable is cell class put when I try parse it to the cellstr fucntion it throws the following error...

cellstr(sentiment) Error using cellstr (line 32) Input must be a string.

I am trying to use the unique command but it throws this error... Error using cell/unique (line 85) Input A must be a cell array of strings.

When I open the variable there is a single column with sentiments positive, negative, neutral but it looks like each cell has a sub-cell. Could this be a reason for the errors? If so how would I correct this ?

I take a cell array that contains some unnecessary characters so i filter out for the relevant word using:

for i= 1:length(sentdate)
s=sentiment{i};
sentiment{i}={s(15:22)};

s2=date{i};
date{i}={s2(17:26)};

Thanks in advance

1
  • You need to show your actual code. Commented Nov 21, 2014 at 17:42

1 Answer 1

2

You don't need the curly brackets around whatever you're assigning into a cell. The assignment is exactly symmetric to reading out the value:

s = sentiment{i};
sentiment{i} = s(15:22);

Surrounding a value with {} actually creates a cell array, which is why you appear to have a subcell. To help understand this difference between () and {}, try this:

sentiment(i) = {s(15:22)};

Same result! By using () to index sentiment, we're not dereferencing the cell contents. So then the value to be assigned must itself be a cell.

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.