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.
回答 (1 件)
per isakson
2012 年 5 月 12 日
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 )
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!