フィルターのクリア

How to list of input, output, signals and its data types used in the simulink model?

11 ビュー (過去 30 日間)
Prashanth
Prashanth 2024 年 5 月 8 日
コメント済み: Prashanth 2024 年 5 月 14 日
How to print the list of input, output, signals and its data types used in the simulink model? "Model data editor" under modelling tab helps in viewing and editing the signals and its data types but how do we print them all separately to a csv/xlsx file? Could anyone please help me that process?

採用された回答

R
R 2024 年 5 月 10 日
The Data Import/Export pane of the Configuration Parameters dialog box includes parameters that configure options for exporting output, signal, and state data from simulations. Refer to the following documentation for more information.
Check the options in the Save to workspace or file section according to your workflow and run the simulation. Once the variables are saved to workspace, you can export them to an excel file. Refer to the following MATLAB Answer to understand how to save workspace variables to an excel file:

その他の回答 (1 件)

Avni Agrawal
Avni Agrawal 2024 年 5 月 10 日
I understand that you are trying to print the list of inputs, outputs, signals, and their data types used in a Simulink model to a CSV/XLSX file, you can use MATLAB scripting to access the model's information programmatically and then write this information to a file. Simulink provides a rich API for interacting with models, including accessing their components and properties.
Here is the code snippet to achieve this:
% Example MATLAB Script to Extract Signal Information from a Simulink Model and Write to CSV
modelName = 'your_model'; % Replace with your Simulink model name
load_system(modelName);
% Find all blocks that have ports (adjust the search to fit your needs)
blocks = find_system(modelName, 'FindAll', 'on', 'type', 'block');
% Initialize a table to hold the data
data = table({}, {}, {}, {}, 'VariableNames', {'BlockName', 'BlockType', 'PortType', 'DataType'});
% Loop through the blocks to get information
for i = 1:length(blocks)
blockName = get_param(blocks(i), 'Name');
blockType = get_param(blocks(i), 'BlockType');
% For each block, you may need to identify if it's an input, output, or signal
% and get its data type. This is a simplified example.
if isprop(handle(blocks(i)), 'CompiledPortDataTypes') % Check if property exists
portDataTypes = get_param(blocks(i), 'CompiledPortDataTypes');
if isfield(portDataTypes, 'Outport') % Example: Check for Outport data type
dataType = portDataTypes.Outport{1}; % Simplified: Assuming first outport
data = [data; {blockName, blockType, 'Outport', dataType}];
end
end
end
% Write the table to a CSV file
writetable(data, 'BAmodel_data.csv');
% Optionally, write to an XLSX file
writetable(data, 'BAmodel_data.xlsx');
I hope this helps!
  1 件のコメント
Prashanth
Prashanth 2024 年 5 月 14 日
Thank you for your repsonse. But this script is printing only the titles, not the signal data.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoad Signal Data for Simulation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by