Fra*_*oro 3 csv modelica export-to-csv mat dymola
我正在使用脚本在 Dymola 中运行大量模拟,到目前为止,效果良好。
但是,它仍然不完整,因为所有结果仍然在 .mat 中,而且我还没有找到自动将它们保存为 .csv 的方法。
我找到了 DataFiles.convertMATtoCSV() 函数,但它要求我指定要导出的变量列表。我希望它导出所有变量,而不需要一一写入,可以吗?
Dymola 手册中,有一节“将所有值保存到 CSV 文件中”。
它包含以下示例代码:
// Define name of trajectory file (fileName) and CVS file
// (CSVfile)
fileName="PID_Controller.mat";
CSVfile="AllVariables.csv";
// Read the size of the trajectories in the result file and
// store in 'n'
n=readTrajectorySize(fileName);
// Read the names of the trajectories
names = readTrajectoryNames(fileName);
// Read the trajectories 'names' (and store in 'traj')
traj=readTrajectory(fileName,names,n);
// transpose traj
traj_transposed=transpose(traj);
// write the .csv file using the package 'DataFiles'
DataFiles.writeCSVmatrix(CSVfile, names, traj_transposed);
Run Code Online (Sandbox Code Playgroud)
这应该做你想做的。如果以后有必要的话,它还提供了定制的空间......