Can't get information in workspace from an S-function in an automated manner
조회 수: 1 (최근 30일)
이전 댓글 표시
I have an S-function that I've built using some referenced c-files, and I want to store some of the properties regarding the names of those files in an automated way. To do so, I search for the block, get its handle, then use sfunctionwizard to get the block data and find the field that I want to reference. It looks like this:
Current_Simulation = 'sys_v5';
blkHandle = find_system(Current_Simulation,'lookundermasks','all','Variants','AllVariants','BlockType','S-Function','FunctionName','PosMPC_new');
bH = get_param(blkHandle{1},'Handle');
appdata = sfunctionwizard(bH,'GetApplicationData');
content = appdata.SfunWizardData.LibraryFilesText;
The problem is that the second-to-last command doesn't always execute in time and the fields don't fully load, causing the S-function builder dialog to appear, along with an error message:
Reference to non-existent field 'SfunWizardData'.
I can get around it by adding a pause() right before the last command, but it's rather finicky. If I run it line-by-line, I don't need the pause. If I run just that section of the script, pause(1) is usually enough. If I run the whole script, I need at least pause(5). I'd like a solution that's more dependable and less arbitrary, and that preferably is as fast as possible.
I've tried using do-nothing while loops (this sometimes works, but only if the counter variable name has a certain minimum length, which is really strange), and using a while loop with isfield() to check if the field exists yet (doesn't work; it just stays in the loop forever). Are there other options that I'm not aware of? Thanks in advance.
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Naming Conventions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!