struggling with 'graph' function in simulink
4 views (last 30 days)
Show older comments
Shemin Sagaria
on 12 Jul 2022
Commented: Shemin Sagaria
on 13 Jul 2022
Hi,
I want to use graph function in simulink matlab function and its showing error. I dont know how else I can perform this,
With Matlab, we can use 'graph' function as follows
s = [1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8];
t = [2 3 8 1 4 8 1 5 8 2 6 7 3 7 6 4 5 7 4 5 6 1 2 3];
g = graph (s,t)
plot (digraph(s,t))
But I cannot use 'graph' function inside MATLAB_function in simulink (error is attached as image - screenshot 22). The code is shared in screenshot 23. Is there any other alternative for this?. I look forward to get some help from experienced users.
I am using MATLAB 2021a
2 Comments
Steven Lord
on 13 Jul 2022
Please show the full and exact text of the error message(s) you received when you tried to use a graph object in a MATLAB Function block in Simulink. Also please tell us what release you're using, as it might be possible to do what you want just in a later release than the one you're using, and what functions you're calling on your graph object.
Accepted Answer
Walter Roberson
on 13 Jul 2022
If you do not need Rapid Acceleration mode, or deployment to hardware, then you can use graph plotting in Simulink. For example,
function y = fcn()
coder.extrinsic('graph')
s = [1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8];
t = [2 3 8 1 4 8 1 5 8 2 6 7 3 7 6 4 5 7 4 5 6 1 2 3];
g = graph (s,t)
plot (g)
y = 0;
which succeeded for me even in Acceleration mode.
Beyond that point, if you need Rapid Acceleration or deploying to hardware, you run into the general problem that plotting is not supported for those modes except through plotting-specific blocks (such as Scope blocks)
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!