구조체 변수가 있고 필드를 추가하고 행의 값을 배열 (double)로 채우고 싶습니다. 다음 코드는 작동하지만별로 좋지 않습니다. mat2cell 함수 나 for 루프를 사용하지 않고 값을 포함한 필드를 추가하는 더 우아한 방법이 있습니까?배열 (double)을 구조체 변수에 필드로 추가하는 방법은 무엇입니까?
field1 = 1:10
field2 = 4:13
%create struct with field 'start' with 10 values
A = struct('start',mat2cell(field1,1,ones(1,numel(field1))))
%transform field2 to cell
temp = mat2cell(field2,1,ones([numel(field2),1]));
%add field 'end' with 10 values
[A(1:numel(field2)).end] = temp{:};