Exporting vectors/matrixes in simulation script to a .csv or excel file?

I have been trying to run simulation scripts and output desired values in a matrix, with a column for time and other parameters, rms values etc.

Is there anyway I can export these data tables to an excel file, so that I may do statistical analysis of these collected data points?

1 Like

Hello Joelkirkby,

As far as I can tell Plecs does not seem to support “csvwrite”, “dlmwrite” or “xlswrite” at this time, “save” however does work. A command as below will save your data without headers in text format to a file. If you open the generated file in a text editor and find/replace all space (" “) characters with commas (”,") excel will correctly load the file as csv.

Example:data = [ 1:3; 4:6; 7:9 ];save(“-ascii”, “data.csv”, “data”);

There may be a better way but this seems somewhat workable.

Best regards,

Chris

Hello,

Are you generating the data from within the simulation script or using signal condition blocks in your model? In the case of the latter, have you tried using the To File block in PLECS’ System component library? It can automatically generate a .CSV file for you.

Best,

Kris