Borrar filtros
Borrar filtros

Problem with Empty matrix: 1-by-0

4 visualizaciones (últimos 30 días)
SreeHarish Muppirisetty
SreeHarish Muppirisetty el 20 de Ag. de 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 comentario
SreeHarish Muppirisetty
SreeHarish Muppirisetty el 22 de Ag. de 2013
I did the following checks:
(~isempty(missinglabelsinimage{1}))
ans =
0
(~isempty(leftoverROI1s{1}))
ans =
1
missinglabelsinimage{1}
ans =
Empty matrix: 1-by-0

Iniciar sesión para comentar.

Respuestas (1)

Iain
Iain el 20 de Ag. de 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 comentario
SreeHarish Muppirisetty
SreeHarish Muppirisetty el 20 de Ag. de 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

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by