Borrar filtros
Borrar filtros

Concatenate fields of two different structures based on two conditions results in Index exceeds array bound help!

1 visualización (últimos 30 días)
I have two structures with Struct1(1 by 40) fields Date and Time (scalars), and Struct2(1 by 100) fields Date1 and Time1 which are vectors. Now I want to attach the fields Date1 and Time1 in struct2 to struct1 if Date=Date1, and Time=Time1. Notice one is scalar and other is vector. My code is as follows. But i get the error as Index in position 1 exceeds array bounds.
Any suggestion is highly appreciated !!!
StartTime=[];
for ii = 1: length(Struct1)
for jj = 1: length(Struct2)
for kk = 1: length(Struct2(ii).Time1)
if Struct1(ii).Date==Struct2(jj).Date1(kk,1) || abs(Struct1(ii).Time - Struct2(jj).Time1(kk,1)) <= 3000
Struct1(ii).StartTime(kk,1) = vertcat(StartTime,Struct2(jj).Time1(kk,1)) ;
else jj = jj+1;
end
end
end
end

Respuestas (0)

Categorías

Más información sobre Structures 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