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.
回答(1 个)
Star Strider
2015-8-20
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 个评论
Mohanlall
2015-8-20
Star Strider
2015-8-20
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
2015-8-20
Star Strider
2015-8-20
My pleasure!
If my Answer solved your problem, please Accept it.
类别
在 帮助中心 和 File Exchange 中查找有关 Numeric Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!