Filter löschen
Filter löschen

Removing Targetlink dependencies from Simulink blocks.

23 Ansichten (letzte 30 Tage)
Thor
Thor am 9 Nov. 2023
Beantwortet: atharva am 9 Nov. 2023
I have been given a large model that was developed using Targetlink blocks that have a dependancy on R2017b Matlab. In order for me to integrate this into a test envirionment I need to convert all the Targetlink blocks used in a large model into Simulink blocks. I can remove them on a per block basis, but wanted to automate this process so it does not take a long time. Is there a way to convert Targetlink blocks into Simulink blocks on an entire model or subsystem basis?
Kind Regards,
Thor Hoffman

Antworten (1)

atharva
atharva am 9 Nov. 2023
Hey Thor,
I understand that you want to automate the process of converting TargetLink blocks into Simulink blocks.
There isn't a direct built-in tool in Simulink that can automatically convert TargetLink blocks to Simulink blocks. However, you may consider the following semi-automated approach:
  • MATLAB provides scripting capabilities that you can use to automate some aspects of the conversion.
  • Use MATLAB commands to iterate through the blocks in your model, identify TargetLink blocks, and replace them with Simulink blocks.
  • Be cautious when using scripting to modify models, as it requires a good understanding of the model structure and Simulink API.
Here is a simplified example script in MATLAB that you might use as a starting point:
% Load the Simulink model
model_name = 'your_model';
open_system(model_name);
% Get all blocks in the model
blocks = find_system(model_name, 'SearchDepth', 1, 'Type', 'Block');
% Iterate through blocks and replace TargetLink blocks with Simulink blocks
for i = 1:length(blocks)
if strcmp(get_param(blocks{i}, 'BlockType'), 'TargetLinkBlockType')
% Replace with Simulink block (replace 'YourSimulinkBlock' with the appropriate block type)
new_block = replace_block(blocks{i}, 'YourSimulinkBlock', 'noprompt');
% Copy parameters from the old block to the new block as needed
% (you may need to adjust this based on your specific use case)
copy_block_parameters(blocks{i}, new_block);
% Delete the old TargetLink block
delete_block(blocks{i});
end
end
Remember to adapt the script based on your specific TargetLink blocks and the corresponding Simulink blocks you want to use.
Before running any script, make sure to create a backup of your model, as automated scripts can have unintended consequences.
Here are the Mathworks documentation links-
I hope this helps!

Kategorien

Mehr zu Subsystems finden Sie in Help Center und File Exchange

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by