function that list inport names of a simulink model in matlab
main.m
functionlist = getSimulinkModelBlockNames(modelName)% This function returns a list of all block names in a Simulink model% Usage: list = getSimulinkModelBlockNames('modelName')% Load the modelload_system(modelName);
% Get a handle to the root of the modelroot = get_param(modelName,'Object');
% Get all the blocks in the modelblocks = find(root,-isa(root,'Simulink.Block'));
% Extract the block names and store in a cell arraylist = cell(length(blocks),1);
fori = 1:length(blocks)
list{i} = get(blocks(i),'Name');
end% Unload the modelunload_system(modelName);
581 chars
22 lines
Simply run this function with the name of the Simulink model as the input argument, and it will return a cell array containing the names of all blocks in the model.