How can I vectorize copying one struct to another?
Mostrar comentarios más antiguos
I have
p.Results.events(i)
ans =
struct with fields:
message: {16×1 cell}
time: [16×1 uint32]
and
obj.data{1}
ans =
1×70 struct array with fields:
gx
gy
time
events
where for example
obj.data{1}(1).gx(1:10)
ans =
532.4000 532.3000 532.2000 531.8000 531.1000 530.2000 528.9000 527.6000 527.3000 527.9000
I was able to do this using
[obj.data{1}.gx] = p.Results.x{:};
[obj.data{1}.gy] = p.Results.y{:};
[obj.data{1}.time] = p.Results.time{:};
for i = 1:70
obj.data{1}(i).events = p.Results.events(i);
end
It seems like in theory, copying the struct should be the easiest to vectorize but I've hit a wall. If it helps, I know exactly what the fields of events should be.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Cell Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!