How to fix Cell contents assignment to a non-cell array object ERROR?
Show older comments
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)
Star Strider
on 20 Aug 2015
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
Mohanlall
on 20 Aug 2015
Star Strider
on 20 Aug 2015
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
Mohanlall
on 20 Aug 2015
Star Strider
on 20 Aug 2015
My pleasure!
If my Answer solved your problem, please Accept it.
Categories
Find more on Numeric Types 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!