If I understand correctly, what you want is:
for i=1:length(files)
for j=1:length(files(i,1).day)
if ((1:length(files(i,1).day(j).hour)) ~= 24)
continue
end
for h = 1:24
if ((length(files(i,1).day(j).hour(h).halfhour)) ~= 2)
break
end
if isempty(files(i,1).day(j).hour)
break
end
dayPSD = [];
for h2=1:2
dayPSD = [dayPSD; files(i,1).day(j).hour(h).halfhour(h2).data{8}'];
end
end
end
end
so when either condition is met, the flow of execution will exit the for h=..
loop, and as there is no other statement in the for j=1...
loop, the code will in effect skip that iteration.
Also note that if ((1:length(files(i,1).day(j).hour(h).halfhour)) ~= 2)
is comparing a vector (1:length(..))
to a scalar 2
which results in a vector of booleans. The if
part will only be executed if all its elements are true
which is most likely never the case.