Filter löschen
Filter löschen

Problem with Empty matrix: 1-by-0

4 Ansichten (letzte 30 Tage)
SreeHarish Muppirisetty
SreeHarish Muppirisetty am 20 Aug. 2013
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 Kommentar
SreeHarish Muppirisetty
SreeHarish Muppirisetty am 22 Aug. 2013
I did the following checks:
(~isempty(missinglabelsinimage{1}))
ans =
0
(~isempty(leftoverROI1s{1}))
ans =
1
missinglabelsinimage{1}
ans =
Empty matrix: 1-by-0

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Iain
Iain am 20 Aug. 2013
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 Kommentar
SreeHarish Muppirisetty
SreeHarish Muppirisetty am 20 Aug. 2013
Hi,
I did the following checks:
(~isempty(missinglabelsinimage{1}))
ans =
0
(~isempty(leftoverROI1s{1}))
ans =
1
missinglabelsinimage{1}
ans =
Empty matrix: 1-by-0

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by