create structure with "fahrzeugid" and "sop" and fill it within a loop in matlab

To create a structure with "fahrzeugid" and "sop", you can use the struct function in MATLAB. Here's an example code snippet:

main.m
% Create an empty array of structures
myStruct = struct('fahrzeugid', {}, 'sop', {});

% Loop through your data and populate your structure
for i = 1:length(myData)
    % Get the fahrzeugid and sop for this iteration
    currentFahrzeugid = myData(i).fahrzeugid;
    currentSop = myData(i).sop;
    
    % Create a structure with this data
    newData = struct('fahrzeugid', currentFahrzeugid, ...
                     'sop', currentSop);

    % Add the new structure to your array of structures
    myStruct(end+1) = newData;
end
531 chars
17 lines

In this example, myData is assumed to be a struct array with fields fahrzeugid and sop. The loop goes through each element in myData, creates a new structure with the fahrzeugid and sop fields, and appends this structure to the myStruct array.

gistlibby LogSnag