Using graph theory inside Simulink

3 次查看(过去 30 天)
Hello, I want to use the graph theory inside Simulink to generate C-Code after (https://fr.mathworks.com/help/bioinfo/ug/graph-theory-functions.html), but I am facing these issues :
Graph variables aren’t handle by data dictionaries, but are inside base and model workspace
There is no Simulink block to use directly graphs
In a Matlab function block, I can load a graph from Model Workspace, as data parameter but Simulink won’t handle it :
  • Error : Expression 'myGraph' for initial value of data 'myGraph' must evaluate to logical or supported numeric type.
I used a very simple graph and it has only scalar string types for Variables
  • Edge_Table = table(["1" "2"; "2" "3"], 'VariableNames', {'EndNodes'});
  • myGraph = graph(Edge_Table);
My conclusion is we can’t use graph theory variables and functions and Simulink, the only way to use it it’s to use Matlab with functions or scripts and inside Matlab create graphs and use functions, then convert results in supported data to Simulink (like doubles) and use simin and simout blocks. But after all that, I am not sure we would be able to generate C-Code.
I would like to know if my conclusion is correct or if there are other ways to use graphs in Simulink. Thank you in advance for your help.

采纳的回答

Steven Lord
Steven Lord 2022-7-1
Some of the "Graph and Network Algorithms" functions in MATLAB support the C/C++ Code Generation extended capability, as you can see by clicking the check box next to that capability in the left frame of that page. Some of those functions that support C/C++ Code Generation do have limitations or notes about that support, which you can read in the Extended Capabilities sections on their individual documentation pages.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by