How do I display simulink simulation data as a table
51 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dieter
el 12 de Abr. de 2024
Comentada: Dieter
el 17 de Abr. de 2024
I would like to generate a simple table with the data from a Simulink simulation. Basically just a table with column labels in the top row, time in the first column and the data from logged values in each column. How do I generate this table?
I just want my model to put out something I can read from in Matlab easily to generate other tables. I have been using the export function in the simulink data inspector to get the data to excel, but I would like to move to dealing with the tables in Matlab as I have to run a bunch of simulations simultaneously and compile the data from multiple simulations into tables.
I am struggling finding ways to reference the data from simulink output in codes to write scripts to generate the tables that I want and at this point can't seem to reference the output data.
0 comentarios
Respuesta aceptada
Ayush Modi
el 12 de Abr. de 2024
Hi Dieter,
I understand you want to get the output of simulink model in the MATLAB workspace, so that you can create a table from that data.
Please refer to the following MathWorks documentation for information on how to save or log the simulation data to the workspace:
Once you have the data in the workspace, here is how you can create a table with the specified requirement:
% Assuming your data is logged to a variable named 'logsout'
% and you want to create a table with time and these signals
% tout is the time output from the simulation data
% Initialize a table with the time column
T = table(tout, 'VariableNames', {'Time'});
% Loop through each element in the dataset to add it to the table
for i = 1:logsout.numElements
% Get the signal name
signalName = logsout.getElement(i).Name;
% Get the signal data
signalData = logsout.getElement(i).Values.Data;
% Add the data as a new column in the table
T.(signalName) = signalData;
end
% Now, T is a table with time and all your logged signals
Hope this helps!
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Sources en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!