Welcome to the TRNSYS Users Forum.

The forum is a place where people can interact and have discussions about different topics involving the use of the TRNSYS software package. Here you can post topics for discussion or questions on using TRNSYS and get advice from other users or TRNSYS experts. This forum is not intended for detailed technical support. Users should contact their distributor’s hotline for such assistance.

Some tips for success on using the forum:

  • Follow the Forum Rules posted in Forum Administration.
  • There are categories for different types of topics and questions. Post your topic or question into the proper category.
  • Before posting a topic or question search the existing topics  (and the TRNSYS Users listserv archive or Post archive) to see if a similar topic or question has already been answered.
  • Use a descriptive topic name. Don’t use attention getting subjects, they don’t get attention and only annoy people.
  • State the version of TRNSYS and which add-ons your are using.
  • Include enough specific details for your topic of question to be answered. Just posting “Why am I getting an error?” without describing the specific error and what you are trying to do when you get the error will not receive a response that fixes your issue.
  • Remember when people help you, they are doing you a favor. Be patient, help people out by posting good descriptions of what you need help with, and be polite even if a response does not solve your issue.
  • Moderators may edit your post for clarity or move your topic to a more appropriate category.

Notifications
Clear all

Issue with linking Matlab file with TRNSYS

3 Posts
2 Users
0 Reactions
402 Views
0
Topic starter

Hello community,

I'm facing a problem linking a Matlab file with Trnsys 18. After validation that the code is correct, I tried to link it with TRNSYS using these instructions:

% Read input data from file
Tambs = trnInputs(1);
vext = trnInputs(2);
G1 = trnInputs(3);
RHamb = trnInputs(4);

% --- Set outputs ---
trnOutputs(1) = X;
trnOutputs(2) = Ta;
trnOutputs(3) = Tb;

but it keeps giving me an error related to mFileErrorCode (Message : The M-File has flagged an error. Returned value for 'mFileErrorCode': 130.0000000000000 . The error occurred at info(7) = 0 , info(13) = 0)

I don't know how I should set and use this mFileErrorCode. Can you please give me tips or instructions i can use to solve this issue and thank you so much.

1 Answer
0

@salwa

It is a bit unclear to me when the error is occurring. Do you get this error as soon as you launch the coupled simulation? If so then I would recommend looking at the Type155 documentation; it contains the entire knowledge base including some troubleshooting tips as concerns the connection between TRNSYS and Matlab.

If the error is getting thrown at some point during the simulation (such that you know that the problem is not in the communication between TRNSYS and Matlab but in the computations) then I would suggest trying to add some code to your m-file that creates its own output file where it can write the values of key variables as it receives them from Trnsys and as it carries out its calculations. There may be a division by zero or some other unexpected math error hiding somewhere.

kind regards,

 David

 

salwa Topic starter 10/01/2024 11:52 am

@davidbradley
Thank you so much for your reply. I checked the Type155 documentation as you suggested, and I followed the instructions to add it to my code. And after I run the simulation, here is what appears:

DavidBradley 15/01/2024 2:59 pm

@salwa
When we compile Type155, we have to link it to four *.lib files. The *.lib file that is referenced in your screen capture (libmx.dll) is one of those libraries. Unfortunately an "access violation" is a very generic message that doesn't really give much useful information. It may be a silly question but are you sure that the version of Type155.dll you are running corresponds to the version of Matlab that you are running?

Share: