How can I use geoplot function in Simulink?
4 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I have a simulink model and also an m-file including geoplot function.
I am trying to run the simulink model and m-file at the same time like using matlab function block but it is not possible beacause of the geoplot function.
Do you think is there another way?
0 个评论
采纳的回答
Suraj
2023-4-24
Hello Reza
I understand that you would like to run a script, that uses “geoplot”, from your Simulink model. If you have tried achieving this using “MATLAB Function” block it should produce an error. This is because “MATLAB Function” block checks for errors that might occur during codegen, and “geoplot” is not supported for code generation. Here is the supporting documentation for this error - https://www.mathworks.com/help/coder/ug/function-is-not-supported-for-code-generation.html
However, if you bypass the code-generation step and instead use the MATLAB engine for execution, the script should run as expected. For this you need to declare your function as “extrinsic”.
Below is a template you can follow for the code in the MATLAB function block. Assume that your script is saved as “myPlotFcn.m”
function fcn()
coder.extrinsic('myPlotFcn')
myPlotFcn()
You can read more about this here - https://www.mathworks.com/help/simulink/ug/use-matlab-engine-to-execute-a-function-call-in-generated-code.html.
1 个评论
Francesco Ciocca
2023-5-22
really thank you for your answer, I found it while searching for a simular issue.
I wanted to implement geoplot in Simulink, but I've understood that it is not possible. What I'm trying to achieve is something like: when I run the Simulink model, somehow a figure appears that represents the geoplot of something.
So, as you suggested, I've written a script on Matlab with inside the geoplot function and therefore I tryed to recall the .m script inside a MatlabFunctionBlock inside Simulink.
The problem is that Simulink presents an error "This text contains non-empty top-level expressions. It appears to be a script."
Would you kindly have any suggestion to solve this problem?
Thank you very much for the patience.
Francesco
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!