How to fix Cell contents assignment to a non-cell array object ERROR?
Mostrar comentarios más antiguos
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.
Respuestas (1)
Star Strider
el 20 de Ag. de 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 comentarios
Mohanlall
el 20 de Ag. de 2015
Star Strider
el 20 de Ag. de 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
el 20 de Ag. de 2015
Star Strider
el 20 de Ag. de 2015
My pleasure!
If my Answer solved your problem, please Accept it.
Categorías
Más información sobre Numeric Types en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!