フィルターのクリア

Problem with Empty matrix: 1-by-0

4 ビュー (過去 30 日間)
SreeHarish Muppirisetty
SreeHarish Muppirisetty 2013 年 8 月 20 日
My variables and their values, in the 'If' condition statement
leftoverROI1s{1}= [11 15];
missinglabelsinimage{1} is an empty matrix.
I want to execute a 'for' loop only if both my conditions in the 'if' statement are true, i.e.,: if((~isempty(leftoverROI1s{1})) && (~isempty(missinglabelsinimage{1})))
for % loop for each element in non-empty missinglabelsinimage structure array. Add a scalar to each element of non-empty missinglabelsinimage structure array
end % end for loop
end % end if
My program control is going into for loop (which I expect, it shouldn't if there is an empty missinglabelsinimage{1}) and the control is working on 'missinglabelsinimage{1}' (empty matrix), which obviously gives me an error as I am trying to add a scalar to my 'non-empty' missinglabelsinimage{1}.
I am not able to understand the error in my if condition. Any help would be appreciated.
Thanks in advance for your time
Best
Harish
  1 件のコメント
SreeHarish Muppirisetty
SreeHarish Muppirisetty 2013 年 8 月 22 日
I did the following checks:
(~isempty(missinglabelsinimage{1}))
ans =
0
(~isempty(leftoverROI1s{1}))
ans =
1
missinglabelsinimage{1}
ans =
Empty matrix: 1-by-0

サインインしてコメントする。

回答 (1 件)

Iain
Iain 2013 年 8 月 20 日
Before the if statement, add
disp(~isempty(leftoverROI1s{1}))
disp(~isempty(missinglabelsinimage{1}))
If both turn up with "1", you'll go into the loop. I suspect that missinglabelsinimage{1} contains a 1x1 cell array with an empty in it.
  1 件のコメント
SreeHarish Muppirisetty
SreeHarish Muppirisetty 2013 年 8 月 20 日
Hi,
I did the following checks:
(~isempty(missinglabelsinimage{1}))
ans =
0
(~isempty(leftoverROI1s{1}))
ans =
1
missinglabelsinimage{1}
ans =
Empty matrix: 1-by-0

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by