Problem with Empty matrix: 1-by-0

4 次查看(过去 30 天)
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
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
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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by