


{"id":398566,"date":"2024-12-27T02:15:40","date_gmt":"2024-12-27T02:15:40","guid":{"rendered":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/ansys-udf-linking-matlab\/"},"modified":"2024-12-27T02:15:40","modified_gmt":"2024-12-27T02:15:40","slug":"ansys-udf-linking-matlab","status":"publish","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/ansys-udf-linking-matlab\/","title":{"rendered":"Ansys UDF (Linking MATLAB)"},"content":{"rendered":"<p>&lt;p&gt;Hi all,&lt;\/p&gt;&lt;p&gt;I am working on the 3D-1D coupling of airflow in the airway tree. As such I need to couple my 3D model in Ansys Fluent with my 1D model in MATLAB. The 1D model will serve as my user-defined boundary condition for the 3D model outlets. I have attempted running a sample .c code for my udf but have been unable to get my code to compile. I am using visual studio as my compiler. Under environmental variables, i have added the PATH (C:\\Program Files\\MATLAB\\R2023b\\bin\\win64 and C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\Hostx64\\x64) , INCLUDE (C:\\Program Files\\MATLAB\\R2023a\\extern\\include), and LIB (C:\\Program Files\\MATLAB\\R2023a\\extern\\lib\\win64\\microsoft) for MATLAB. I believe I have done everything i need to do but I still end up with error messages below. It seems as though the compiler isnt finding the MATLAB LIB although i have specified it under environmental variables. Any help with this would be very much appreciated. I have tried alot of online suggestions and spent two long weeks trying to figure this out and still don&#8217;t have a solution.&nbsp;&nbsp;&lt;\/p&gt;&lt;p&gt;&lt;span style=&#8221;text-decoration: underline;&#8221;&gt;<strong>Error Message<\/strong>&lt;\/span&gt;&lt;\/p&gt;&lt;p&gt;Copyright 1987-2024 ANSYS, Inc. All Rights Reserved.&lt;\/p&gt;&lt;p&gt;Compiler and linker: Microsoft Visual C++&lt;\/p&gt;&lt;p&gt;# Generating ud_io1.h&lt;\/p&gt;&lt;p&gt;Testcode.c&lt;\/p&gt;&lt;p&gt;# Generating udf_names.c because of makefile Testcode.obj&lt;\/p&gt;&lt;p&gt;udf_names.c&lt;\/p&gt;&lt;p&gt;# Linking libudf.dll because of makefile user_nt.udf udf_names.obj Testcode.obj&lt;\/p&gt;&lt;p&gt;Creating library libudf.lib and object libudf.exp&lt;\/p&gt;&lt;p&gt;Testcode.obj : error LNK2019: unresolved external symbol engEvalString referenced in function matlab_test&lt;\/p&gt;&lt;p&gt;Testcode.obj : error LNK2019: unresolved external symbol engOpen referenced in function matlab_test&lt;\/p&gt;&lt;p&gt;Testcode.obj : error LNK2019: unresolved external symbol engClose referenced in function matlab_test&lt;\/p&gt;&lt;p&gt;libudf.dll : fatal error LNK1120: 3 unresolved externals&lt;\/p&gt;&lt;p&gt;NMAKE : U1077: &#8216;link -nologo \/Libpath:&#8221;C:\\PROGRA~1\\ANSYSI~1\\ANSYSS~1\\v242\\fluent&#8221;\\fluent24.2.0\\win64\\3d_node \/Libpath:&#8221;C:\\PROGRA~1\\ANSYSI~1\\ANSYSS~1\\v242\\fluent&#8221;\\fluent24.2.0\\multiport\\win64\\mpi\\shared \/dll \/out:libudf.dll udf_names.obj Testcode.obj mport.lib fl_mpi2420.lib &#8216; : return code &#8216;0x460&#8242;&lt;\/p&gt;&lt;p&gt;Stop.&lt;\/p&gt;&lt;p&gt;<strong>&lt;span style=&#8221;text-decoration: underline;&#8221;&gt;UDF Code&lt;\/span&gt;<\/strong>&lt;\/p&gt;&lt;p&gt;#include &#8220;udf.h&#8221; \/\/ Fluent UDF header&lt;br&gt;#include &#8220;engine.h&#8221; \/\/ MATLAB Engine header&lt;br&gt;#include &lt;stdio.h&gt;&lt;\/p&gt;&lt;p&gt;\/\/ Example UDF using MATLAB Engine&lt;br&gt;DEFINE_EXECUTE_AT_END(matlab_test)&lt;br&gt;{&lt;br&gt;&nbsp; &nbsp; Engine *ep = engOpen(NULL); \/\/ Open MATLAB engine&lt;br&gt;&nbsp; &nbsp; if (ep == NULL)&lt;br&gt;&nbsp; &nbsp; {&lt;br&gt;&nbsp; &nbsp; &nbsp; &nbsp; Message(&#8220;Error: Unable to start MATLAB engine.\\n&#8221;);&lt;br&gt;&nbsp; &nbsp; &nbsp; &nbsp; return;&lt;br&gt;&nbsp; &nbsp; }&lt;\/p&gt;&lt;p&gt;&nbsp; &nbsp; Message(&#8220;MATLAB engine started successfully.\\n&#8221;);&lt;\/p&gt;&lt;p&gt;&nbsp; &nbsp; \/\/ Example MATLAB engine command&lt;br&gt;&nbsp; &nbsp; engEvalString(ep, &#8220;disp(&#8216;Hello from MATLAB Engine!&#8217;);&#8221;);&lt;\/p&gt;&lt;p&gt;&nbsp; &nbsp; engClose(ep); \/\/ Close MATLAB engine&lt;br&gt;&nbsp; &nbsp; Message(&#8220;MATLAB engine closed successfully.\\n&#8221;);&lt;br&gt;}&lt;\/p&gt;<\/p>\n","protected":false},"template":"","class_list":["post-398566","topic","type-topic","status-publish","hentry","topic-tag-fluent-ansys-1","topic-tag-udf","topic-tag-udferror"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"Hi all,I am working on the 3D-1D coupling of airflow in the airway tree. As such I need to couple my 3D model in Ansys Fluent with my 1D model in MATLAB. The 1D model will serve as my user-defined boundary condition for the 3D model outlets. I have attempted running a sample .c code\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/ansys-udf-linking-matlab\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Ansys Learning Forum | Ansys Innovation Space\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Ansys UDF (Linking MATLAB) | Ansys Learning Forum\" \/>\n\t\t<meta property=\"og:description\" content=\"Hi all,I am working on the 3D-1D coupling of airflow in the airway tree. As such I need to couple my 3D model in Ansys Fluent with my 1D model in MATLAB. The 1D model will serve as my user-defined boundary condition for the 3D model outlets. I have attempted running a sample .c code\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/ansys-udf-linking-matlab\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2024-12-27T02:15:40+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2024-12-27T02:15:40+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Ansys UDF (Linking MATLAB) | Ansys Learning Forum\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Hi all,I am working on the 3D-1D coupling of airflow in the airway tree. As such I need to couple my 3D model in Ansys Fluent with my 1D model in MATLAB. The 1D model will serve as my user-defined boundary condition for the 3D model outlets. I have attempted running a sample .c code\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/ansys-udf-linking-matlab\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"name\":\"Topics\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/udf\\\/#listItem\",\"name\":\"udf\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/udf\\\/#listItem\",\"position\":3,\"name\":\"udf\",\"item\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/udf\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/ansys-udf-linking-matlab\\\/#listItem\",\"name\":\"Ansys UDF (Linking MATLAB)\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"name\":\"Topics\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/ansys-udf-linking-matlab\\\/#listItem\",\"position\":4,\"name\":\"Ansys UDF (Linking MATLAB)\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/udf\\\/#listItem\",\"name\":\"udf\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#organization\",\"name\":\"Ansys Learning Forum\",\"description\":\"Ansys Innovation Space\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/ansys-udf-linking-matlab\\\/#webpage\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/ansys-udf-linking-matlab\\\/\",\"name\":\"Ansys UDF (Linking MATLAB) | Ansys Learning Forum\",\"description\":\"Hi all,I am working on the 3D-1D coupling of airflow in the airway tree. As such I need to couple my 3D model in Ansys Fluent with my 1D model in MATLAB. The 1D model will serve as my user-defined boundary condition for the 3D model outlets. I have attempted running a sample .c code\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/ansys-udf-linking-matlab\\\/#breadcrumblist\"},\"datePublished\":\"2024-12-27T02:15:40+00:00\",\"dateModified\":\"2024-12-27T02:15:40+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#website\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/\",\"name\":\"Ansys Learning Forum\",\"description\":\"Ansys Innovation Space\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Ansys UDF (Linking MATLAB) | Ansys Learning Forum","description":"Hi all,I am working on the 3D-1D coupling of airflow in the airway tree. As such I need to couple my 3D model in Ansys Fluent with my 1D model in MATLAB. The 1D model will serve as my user-defined boundary condition for the 3D model outlets. I have attempted running a sample .c code","canonical_url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/ansys-udf-linking-matlab\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BreadcrumbList","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/ansys-udf-linking-matlab\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum#listItem","position":1,"name":"Home","item":"https:\/\/innovationspace.ansys.com\/forum","nextItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","name":"Topics"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","position":2,"name":"Topics","item":"https:\/\/innovationspace.ansys.com\/forum\/topics\/","nextItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/udf\/#listItem","name":"udf"},"previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/udf\/#listItem","position":3,"name":"udf","item":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/udf\/","nextItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/ansys-udf-linking-matlab\/#listItem","name":"Ansys UDF (Linking MATLAB)"},"previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","name":"Topics"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/ansys-udf-linking-matlab\/#listItem","position":4,"name":"Ansys UDF (Linking MATLAB)","previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/udf\/#listItem","name":"udf"}}]},{"@type":"Organization","@id":"https:\/\/innovationspace.ansys.com\/forum\/#organization","name":"Ansys Learning Forum","description":"Ansys Innovation Space","url":"https:\/\/innovationspace.ansys.com\/forum\/"},{"@type":"WebPage","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/ansys-udf-linking-matlab\/#webpage","url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/ansys-udf-linking-matlab\/","name":"Ansys UDF (Linking MATLAB) | Ansys Learning Forum","description":"Hi all,I am working on the 3D-1D coupling of airflow in the airway tree. As such I need to couple my 3D model in Ansys Fluent with my 1D model in MATLAB. The 1D model will serve as my user-defined boundary condition for the 3D model outlets. I have attempted running a sample .c code","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/#website"},"breadcrumb":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/ansys-udf-linking-matlab\/#breadcrumblist"},"datePublished":"2024-12-27T02:15:40+00:00","dateModified":"2024-12-27T02:15:40+00:00"},{"@type":"WebSite","@id":"https:\/\/innovationspace.ansys.com\/forum\/#website","url":"https:\/\/innovationspace.ansys.com\/forum\/","name":"Ansys Learning Forum","description":"Ansys Innovation Space","inLanguage":"en-US","publisher":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/#organization"}}]},"og:locale":"en_US","og:site_name":"Ansys Learning Forum | Ansys Innovation Space","og:type":"article","og:title":"Ansys UDF (Linking MATLAB) | Ansys Learning Forum","og:description":"Hi all,I am working on the 3D-1D coupling of airflow in the airway tree. As such I need to couple my 3D model in Ansys Fluent with my 1D model in MATLAB. The 1D model will serve as my user-defined boundary condition for the 3D model outlets. I have attempted running a sample .c code","og:url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/ansys-udf-linking-matlab\/","article:published_time":"2024-12-27T02:15:40+00:00","article:modified_time":"2024-12-27T02:15:40+00:00","twitter:card":"summary_large_image","twitter:title":"Ansys UDF (Linking MATLAB) | Ansys Learning Forum","twitter:description":"Hi all,I am working on the 3D-1D coupling of airflow in the airway tree. As such I need to couple my 3D model in Ansys Fluent with my 1D model in MATLAB. The 1D model will serve as my user-defined boundary condition for the 3D model outlets. I have attempted running a sample .c code"},"aioseo_meta_data":{"post_id":"398566","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2025-10-19 10:43:08","updated":"2026-09-17 14:58:11","ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/innovationspace.ansys.com\/forum\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/innovationspace.ansys.com\/forum\/topics\/\" title=\"Topics\">Topics<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/udf\/\" title=\"udf\">udf<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tAnsys UDF (Linking MATLAB)\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/innovationspace.ansys.com\/forum"},{"label":"Topics","link":"https:\/\/innovationspace.ansys.com\/forum\/topics\/"},{"label":"udf","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/udf\/"},{"label":"Ansys UDF (Linking MATLAB)","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/ansys-udf-linking-matlab\/"}],"acf":[],"custom_fields":[{"0":{"_bbp_forum_id":["27792"],"_bbp_topic_id":["398566"],"_bbp_subscription":["281137","199"],"_bbp_author_ip":["2601:410:4280:4e80:d0a2:e819:3fd9:7e12"],"_bbp_last_reply_id":["404165"],"_bbp_last_active_id":["404165"],"_bbp_last_active_time":["2025-01-08 18:44:52"],"_bbp_reply_count":["2"],"_bbp_reply_count_hidden":["0"],"_bbp_voice_count":["2"],"_bbp_engagement":["281137","199"],"_btv_view_count":["535"],"_bbp_topic_status":["unanswered"]},"test":"emmanuel-akoruiowa-edu"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/398566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/398566\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=398566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}