How can I use geoplot function in Simulink?

조회 수: 4 (최근 30일)
reza
reza 2023년 4월 19일
댓글: Francesco Ciocca 2023년 5월 22일
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?

채택된 답변

Suraj
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()
  댓글 수: 1
Francesco Ciocca
Francesco Ciocca 2023년 5월 22일
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

댓글을 달려면 로그인하십시오.

추가 답변 (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