Why does how I reference data in a cell array change in a for loop?

I am trying to evaluate data in a cell array to input into a new matrix/array. I am simply attempting to evaluate whether values in a cell array are less than a specific number or not. If it is less than, I store 1, if it is greater than, I store 0 in a new matrix.
After trouble shooting for hours, I can only conclude that once in a for loop my cell array does not act as I expect. Here is my code and what I have tried
cell2mat(BONDLEN_1G)
for CL=1:15;
% disp(BONDLEN_1G{CL})
for U=1:END
if BONDLEN_1G{CL}(U,1) <= CUTOFFLENGTH
LOGIC(U,1) = 1; % 1 equals BONDED
% disp(LOGIC)
%disp('^LOGIC^^')
%disp(BONDLEN_1G{CL})
%disp('IF')
% disp('CL')
%disp(CL)
%disp(U)
else
LOGIC(U,1) = 0; % 0 equals NOT BONDED
%disp(BONDLEN_1G{CL})
% disp('ELSE')
% disp('CL2')
% disp(CL)
%disp(U)
end
end
% disp(BONDLEN_1G)
% disp(BONDLEN_1G{CL})
end
Any hints or answers would be greatly appreciated. I am new to cell arrays although I have read most of the documentation and cannot figure out why this simple procedure will not work.

Answers (1)

Do you step through the code with the debugger?
If you want us to try the code you must supply the data needed to run it.
What is this line supposed to do?
cell2mat(BONDLEN_1G)
Is END a variable?
for U=1:END
should possibly be
for U = 1 : length( something )

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 12 May 2012

Community Treasure Hunt

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

Start Hunting!