MATLAB: Delete specific outgoing RMI links programatically

linkRequirementsrmisimulinkSimulink Requirements

I would like to remove a single requirement link from my Simulink object.
I have found that i can clear ALL links using the following command:
>> rmi('clear all',object)
But i don't want to delete all of them, just a specific requirement. How can I do that?

Best Answer

In order to remove one or more requirement links from an object, you will need to copy the current requirement links, remove those that are no longer needed, then assign the edited set of requirements links to the object.
Please refer to the following simplified example where we want to delete the 4th requirement link from a block in the top level of a model, such that the path of the block is 'model/block'.
1. If you do not already have it, get the path to the object you want to remove links from
2. Get the current links for that object using the following command:
>> reqLinks = rmi('get','model/block')
3. The output of this command will be a structure containing all of the current links. The contents of the structure are described in the following documentation:
4. Remove the rows of the structure corresponding to the links you wish to remove. for example, removing the 4th link:
>> reqLinks(4,:) = [] % remove the 4th row
5. Now pass the new requirements link into the rmi function
>> rmi('set','model/block',reqLinks) % pass the updated links structure
6. The block will now have the requirement link removed. You can confirm this by calling the 'get' command from step 2 again.