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!