Why does an 'catch me' error pop up while im running my while loop
9 ビュー (過去 30 日間)
古いコメントを表示
I am trying to compare values in an excel file but i do not know the where the last row of values in the exel file is at so i tried to compare them till the last cell is empty then i stop. But apparently when the code stops when the values has a sudden huge gap difference say from 7 to 11. I want the code to ignore if they cant compare the values and just put a '-' in the cell and continue running the comparison.
b=1;
if ~isempty(num(b,5))
if ismembertol(num(b,5),num(frame,9),0.001)
W = num(b,4);
ChainplusF = Originalchainage + W;
num(frame,8) = ChainplusF;
else
while ~ismembertol(num(b,5),num(frame,9),0.001) && ~isempty(num(b,5))
b=b+1;
if ismembertol(num(b,5),num(frame,9),0.001)
W = num(b,4);
ChainplusF = Originalchainage + W;
num(frame,8) = ChainplusF;
end
end
end
else
num(frame,8) = '-';
end
16 件のコメント
Walter Roberson
2019 年 11 月 5 日
Scalar numeric array entries are never empty.
In Excel itself, it is true that if you attempt to access anything beyond the last filled row, that the cell will be reported as empty. Cells in Excel are more similar to MATLAB cell arrays, in which each has an individual type (and formatting instructions) and so can individually be empty. But in MATLAB, empty always means an array with no elements in it, such as zeros(0,0) also known as [], where there is no "there" there, and a numeric entry of size 1 x 1 has one element not zero elements and so is never considered empty. A numeric entry can have value -inf or +inf or any of thousands of technically different Not A Number values, but if it has at least one value then it is not empty for MATLAB purposes.
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および 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!


