Is there a way to get all the blocks with specific datatype (eg. boolean / ufix1) in Simulink model after compiling
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Omar Zalat
el 19 de Jun. de 2015
Comentada: Omar Zalat
el 22 de Jun. de 2015
Is there a way to get all the blocks with specific datatype (eg. boolean / ufix1) in Simulink model after compiling
0 comentarios
Respuesta aceptada
Sebastian Castro
el 19 de Jun. de 2015
Editada: Sebastian Castro
el 19 de Jun. de 2015
You can't exactly do this for blocks, because some blocks use different data types for different calculations inside of them. What you can do is get the compiled data types of ports, though.
The following code will show you how to do it for all the output ports in the "vdp" shipping example. It should all return double, but try it on one of your models and see what you get!
% Compile the vdp model
vdp([],[],[],'compile');
% Find all blocks in model
allBlocks = find_system('vdp','Type','Block');
% Loop through all blocks
for i = 1:numel(allBlocks)
lh = get_param(allBlocks{i},'PortHandles');
outports = lh.Outport;
% Loop through all output ports
for j = 1:numel(outports)
dataType = get(outports(j),'CompiledPortDataType');
% Display the data type
disp([allBlocks{i} ' output port ' num2str(j) ': ' dataType]);
end
end
% Terminate
vdp([],[],[],'term')
Right... so to get all the blocks with a specific data type, you can use logic like
if strcmp(dataType,'single')
% do something
end
- Sebastian
Más respuestas (0)
Ver también
Categorías
Más información sobre Event Functions 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!