Using OpenFcn to change Simulink mask parameters
Show older comments
Hi,
i have a Simulink mask wich I am using to change parameters of a struct. The parameters of the struct can be modified ba the mask or via a matlab-script. If the parameters of the struct are changed by the script, the parameters in the mask won't be changed. I wanted to try using 'OpenFcn' from BlockProperties of my subsystem to set the mask parameters to those values contained in my struct. At first, I tried a very simple code to see, if I can run some code and open the mask in addition to that.
My Code in the OpenFcn:
disp('LoaderWagon') % to check if the callback works
%Path=Mdl.implement.LibraryPath.blk
Path_testframe='Verification_Trailer' % name of the Library (Trailer) in the testframe model (Verification_Trailer/Implement/...)
Path_trailer='Verification_Trailer/Implement/Trailer'
The code above works. The following code cann not be executed:
open_system('Path_testframe')
disp('1of3') % to see in the previous command works
open_system('Path_trailer')
disp('2of3')
set_param(Path_trailer,'h_G',num2str(h_G));
Simulink gives the foloowing error-message: Recursion detected in the OpenFcn of 'Verification_Trailer/Implement/Trailer'.
Is there anyone who knows how to solve this problem?
Greetings
Answers (1)
Malte Otten
on 4 Mar 2020
1 Comment
Run
on 9 Feb 2021
Add
open_system(gcbh, 'mask');
at the end of your code.
Categories
Find more on Author Block Masks in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!