How do I display simulink simulation data as a table
63 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Ayush Modi
2024 年 4 月 12 日
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!
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Sources についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!