How to append elements in struct array without looping in matlab? -
i want add elements in struct without looping have done below:
test_struct = struct ('item1', {} , 'item2' , {} ) ; k = 1 : 10 test_struct(k).item1 = 1:10 ; test_struct(k).item2 = 2* (1:10) ; end is there way add elements adding elements in list in c#. want dynamic struct array because not know how many elements, have add in it.
code
%%// first data (normal arrays) data1 = 1:10; data2 = 2* (1:10); test_struct1 = struct('item1', {data1}, 'item2', {data2}); %%// new data (normal arrays) appended data1 = 11:20; data2 = 4* (1:15); %%// main step appends new data test_struct1(end+1) = struct('item1', {data1}, 'item2', {data2}); for verification, may use nice tool comparing structures, don't think matlab has built-in function that, not in of previous versions of matlab @ least.
Comments
Post a Comment