"Unable to read some Variables" error when converting to FMU

11 views (last 30 days)
I am able to compile my model successfully and it is giving the expected results. However on trying to convert it to an FMU, I am getting an error "=== Export to Standalone Co-Simulation FMU (Elapsed: 0.76 sec) ===
Error:Unable to read some variables. Variable name lengths must be less than or equal to MATLAB maximum name length of 63 characters.
".
However on checking the variable names in my model, I found out that the variable with the longest name is only 40 characters which is well below the 63 character limit that Matlab enforces. I was able to successfully convert my model into an FMU several times in the past and the only change made in the model now, is an additional input port (whose name length is 11) and an additional output port (whose name length is 6). I tried undoing these changes and generating an FMU but it is throwing up the same error again.
Is there any other model setting which influences this? Has anyone faced a similar issue?
All help and suggestions are appreciated.

Answers (1)

Himanshu
Himanshu on 21 Mar 2024
Hello Ashwin,
I understand that you have successfully compiled your model but you are encountering an error stating, "Unable to read some variables. Variable name lengths must be less than or equal to MATLAB's maximum name length of 63 characters," when attempting to convert it to an FMU.
I faced a similar issue and found a solution that worked for me in MATLAB R2022a. Typically, this problem arises when variable names exceed the maximum length of 63 characters, as discussed in a MATLAB Answers post here:
The real challenge was pinpointing and locating where the error was occurring. Reinstalling MATLAB R2022a fixed this error.
I hope this helps.
  2 Comments
Ashwin
Ashwin on 21 Mar 2024
Hello Himanshu,
Thank you for your answer. I actually found the issue. None of the variable names were more than 63 characters long. The longest variable name was 40 characters only.
The actual reason was target hardware setting in model settings tab. I had set it to Linux64 previously. When I set it back to Win64, the saved cache .slxc file was unable to find the Win64 library in temp folder.
So, I deleted the .slxc and other cache, set target hardware to Win64, saved the model and then restarted Matlab. After this the error was fixed.
(In your case, maybe reinstalling Matlab had the same effect of deleting the cache)
Himanshu
Himanshu on 21 Mar 2024
Hello Ashwin,
Glad to know that your issue was resolved. Thank you for sharing the details of the issue.

Sign in to comment.

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Tags

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!