I have a structure, 'D', which contains 'name'. I would like to assign certain parts of this struct to another struct in an efficient manner. What I have now (which works) is the following:
j = 0;for i = 1:length(D) if ( m_u(i) ~= 0 ) j = j + 1; temp(j).name = D(i).name; endend
In this code, the contents of 'D.name' are assigned to 'temp.name' if a vector component is not zero. Is there a more efficient way to do this?
Best Answer