|Subject:||dumping scalar structure to matrix fails if empty rows exist|
|Date:||Fri, 16 Oct 2015 15:31:07 +0000|
quite new to Octave, I don’t find a solution despite a lot of try and search :
I want to write various scalar structures out to CSV Files, resembling telemetry data with spurious signal drop outs. I can’t influence the
data sent. The code below works as long as all elements are filled.
But if there are columns which do have column headers with empty values related to them, the assignment of this empty row to the prepared target matrix deletes the respective row,
what leads to an “A(I,J,...) = X: dimensions mismatch” error.
Can I somehow prevent Octave from deleting that rows ? Or do I need a sort of “arrayfun” Fu to catch those  cases ? I tried to understand that, but it is beyond my current level..
The resulting CSV File should have the respective column header and empty cells (e.g. ;;) below.
structIn=struct("time",[1 2 3],"up",,"left",,"speed",[22 33]);
%Get each field name from the structure
fieldNames = fieldnames(structIn);
%Create a text string with the field names
headerOut=headerOut(1:end-1); %Trim off last `,` and `\t`
%prepare matrix according to size of struct
%Write to csv.
dlmwrite(‘outfile.csv’, headerOut, '');
dlmwrite(‘outfile.csv’, matOut, '-append');
Knorr-Bremse IT-Services GmbH
Geschäftsführer: Werner Zengler (Vorsitzender), Ansgar Fries
Registergericht München, HR B 167 268
This transmission is intended solely for the addressee and contains confidential information.
If you are not the intended recipient, please immediately inform the sender and delete the message and any attachments from your system.
Furthermore, please do not copy the message or disclose the contents to anyone unless agreed otherwise. To the extent permitted by law we shall in no way be liable for any damages, whatever their nature, arising out of transmission failures, viruses, external influence, delays and the like.
|[Prev in Thread]||Current Thread||[Next in Thread]|