How can I exchange .mat file input data to spreadsheet excel file programatically?

I am looking for a way to programmatically export the input data for the test patterns from the .mat file loaded into Test Manager to an Excel file of type sltest.io.SimulinkTestSpreadsheet in Simulink Test R2023a.
Currently, I am performing this task using the Test Manager menu via the Signal Editor. However, I want to perform this task using commands.

 Respuesta aceptada

The class sltest.io.SimulinkTestSpreadsheet inherits from the class Simulink.io.FileType . This base class has an import/export methods which can also be leveraged with sltest.io.SimulinkTestSpreadsheet. 
Please see this example: https://www.mathworks.com/help/simulink/slref/simulink.io.filetype-class.html#mw_c40e57e4-e5c0-44d9-a15b-aaf78c04b476
https://www.mathworks.com/help/simulink/slref/simulink.io.filetype.exportimpl.html
There is no direct way to convert a MAT to Excel, but similar to the workflow used by you, this can be broken up into a two step process
1. Load the MAT file into a dataset or individual signals
2. Then export this to Excel
I am not showing Step 1 since there are many ways to do so. But let's say you create a Simulink.SimulationData.Dataset, here is one example (similar to the published example):
ds = Simulink.SimulationData.Dataset;
ds = ds.addElement(timeseries([1:10]',[1:10]'),'Siganl1');
ds = ds.addElement(timeseries([1:10]',[11:20]'),'Siganl2');
ds = ds.addElement(timeseries([1:10]',[21:30]'),'Siganl3');
reader = sltest.io.SimulinkTestSpreadsheet('slt_excel.xlsx');
reader.export('slt_excel.xlsx',{'ds'},{ds},0);

Más respuestas (0)

Productos

Versión

R2023a

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by