Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>how would you actually map the struct to a csv? you cannot do a straight forward map of fieldnames as entries on first line, because the matrices have incompatible dimensions. So this example you'd have to 1. introduce several columns for own_dummies and 2. expand the cdindex.</p> <p>So you could write a wrapper to make the matrices themselves compatible and to write the columns yourself into the file. something along the (untested,conceptual) lines of</p> <pre><code> function saveData(filename, data, type) % at first bring struct data to sensible format if strcmp(type)='my_mat_type' data.own_dummies2 = data.own_dummies[2,:]; % split into seperate columns %... data.own_dummies26 = data.own_dummies[26,:]; data.own_dummies = data.own_dummies[1,:]; data.cdindex = [data.cdindex -ones(1,2217-length(data.cdindex)]; % pad any missing values as -1 end; FD = fopen(filename, 'w'); %todo did it open? fields = fieldnames(data); nfields = length(fields); % create column name values columns = strcat(strcat(fields,',')); % creates string = col1,col2,...coln, columns = columns(1:length(columns)-1); %remove trailing comma CRNL = char([10 13]); % or so % print columns and newline fprintf(FD,strcat(columns,CRNL)); dataout = cell2mat(struct2cell(data)); % use your method to write the data to the file fclose(FD); </code></pre> <p>naturally, you could also just split the individual fields into separate files where the fieldname is contained within the filename, which might be simpler, generally speaking.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload