How to fix Cell contents assignment to a non-cell array object ERROR?

Below is my code that keeps outputting the following error: Cell contents assignment to a non-cell array object.
for i=1:10
windowdata{i}=workingdata(window(i):window(i+1));
indvals{i}=find(windowdata{i}>0.2 & windowdata{i}<0.4);
end
Essentially, I am trying to make windowdata a cell array containing data values from a windowed data set. 'Window' is previously define before the for loop. Then, I will extract all indices for which the values of 'windowdata' are above 0.2 and less than 0.4. These values will also be stored into a cell array named 'indvals'.
I am truly at a road block here and would appreciate any help. Thank you.

Answers (1)

You probably defined ‘windowdata’ or ‘indvals’ as something else earlier in your code. The easiest way to fix this is to rename them in your loop to something similar, but not the same.
For example, this code:
windowdata = 1;
windowdata{1} = eps;
throws the same error.

4 Comments

I tried clearing out all variables and double checked to see if the variables were defined elsewhere but they weren't.
Still have the same issue.
What statement is throwing the error? You listed two, but not the detailed error message. Please post the entire red text that appears in the Command Window.
This runs for me without error:
workingdata = rand(1, 110);
window = [1:10:110];
for i=1:10
windowdata{i}=workingdata(window(i):window(i+1));
indvals{i}=find(windowdata{i}>0.2 & windowdata{i}<0.4);
end
UPDATE: THIS WAS THE ISSUE AFTER ALL. THANKS!
My pleasure!
If my Answer solved your problem, please Accept it.

Sign in to comment.

Categories

Asked:

on 20 Aug 2015

Commented:

on 20 Aug 2015

Community Treasure Hunt

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

Start Hunting!