How can I use geoplot function in Simulink?

4 views (last 30 days)
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?

Accepted Answer

Suraj
Suraj on 24 Apr 2023
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()
  1 Comment
Francesco Ciocca
Francesco Ciocca on 22 May 2023
Hi @Suraj,
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

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink Functions 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!