struggling with 'graph' function in simulink

2 visualizaciones (últimos 30 días)
Shemin Sagaria
Shemin Sagaria el 12 de Jul. de 2022
Comentada: Shemin Sagaria el 13 de Jul. de 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 comentarios
Steven Lord
Steven Lord el 13 de Jul. de 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.
Shemin Sagaria
Shemin Sagaria el 13 de Jul. de 2022
Hi,
I have attched the images of the error and my code. The error is in line 10

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Jul. de 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)

Más respuestas (0)

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by