MATLAB deploytool simulink未定义的函数'load_system' [英] MATLAB deploytool simulink Undefined function 'load_system'

查看:1825
本文介绍了MATLAB deploytool simulink未定义的函数'load_system'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用一个MATLAB m文件代码,它加载一个simulink文件,运行它,并在一个复杂的并行循环中评估它多次。



MATLAB环境。当通过 deploytool 命令编译代码,安装它并从命令行运行时,我会有一个困难的时期。



在它加载模型的行,

  mymodel = ...; 
load_system(mymodel);

我收到以下错误

  C:\Program Files\mymain\application>警告:名称不存在或不是目录:model 
>在路径109
在addpath在86
在run_main在3
警告:名称不存在或不是目录:data
>在路径109
在addpath在86
在run_main在4
警告:名称不存在或不是目录:graphics
>在路径为109
在addpath在86
在run_main在5
使用'本地'配置文件启动并行池(parpool)连接到2工人。
初始化...
类型为'char'的输入参数的未定义函数'load_system'。

run_main错误(第40行)


MATLAB:UndefinedFunction

我不关心警告(因为我不在乎大多数其他MATLAB警告),但我得到错误,无法识别功能打开一个simulink模型('load_system'): / p>

 类型为'char'的输入参数的未定义函数'load_system'。 

我做了一个搜索,我发现了以下问题:



。有多种命令行选项用于将新的参数集和输入通过mat文件传递到可执行文件。

  • 在MATLAB代码中:将所有Simulink功能替换为一个调用(通常使用 system 函数,如链接示例中所示)到在步骤1中创建的可执行文件。在此调用之前,您需要创建一个你的所有参数;在调用后,您将需要从可执行文件创建的mat文件中读取结果。

  • 这不是一个简单的过程,是可行的。


    I am using a MATLAB m file code which loads a simulink file, runs it and evaluats it so many times inside a complicated parallel loop.

    It runs perfect at MATLAB environment. When compiling the code via deploytool command, installing it and running it from command line, I would have a difficult time.

    At the line where it is loading the model,

    mymodel= ... ;
    load_system(mymodel);
    

    I get the following error

    C:\Program Files\mymain\application>Warning: Name is nonexistent or not a directory: model
    > In path at 109
      In addpath at 86
      In run_main at 3
    Warning: Name is nonexistent or not a directory: data
    > In path at 109
      In addpath at 86
      In run_main at 4
    Warning: Name is nonexistent or not a directory: graphics
    > In path at 109
      In addpath at 86
      In run_main at 5
    Starting parallel pool (parpool) using the 'local' profile ... connected to 2 workers.
    Initializing ...
    Undefined function 'load_system' for input arguments of type 'char'.
    
    Error in run_main (line 40)
    
    
    MATLAB:UndefinedFunction
    

    I don't care about warnings (as I don't care about most of other MATLAB warnings) however I get error about not recognizing function to open a simulink model ('load_system') :

    Undefined function 'load_system' for input arguments of type 'char'.
    

    I did a search and I found the following questions:

    load_system using MCR

    Deployment of Simulink Models

    The first link says

    I just got confused: is deployment tools about compiling to C++ or to .NET ? Is is supposed to increase speed or becomming stand-alone is the only advantage?

    The problem with both links is that they talk about strategy. But how to implement them? How can I compile a MATLAB code which uses load_system and sim command to load and simulate a model?

    Can anybody bring step by step solution for a very simple example of a MATLAB code (m file) simulating a model and then compiling both of them?

    解决方案

    The first sentence of your documentation screen shot is the important one. As mentioned by @Navan (in a comment), Simulink functionality is not compatible with MATLAB Compiler. That is, any m-code that uses Simulink functinality (load_system, sim, etc) will not execute when using the MATLAB Compiler.

    Assuming that you have access to Simulink Coder, and that your model doesn't contain functionality that prevents it from being converted to c-code, then your only option is to develop your application in two parts:

    1. With your Simulink model: Use Simulink Coder to create an executable from your model. There are several examples of doing this in the doc, including Using RSIM Target for Batch Simulations. There are various command line options for passing new parameter sets and inputs to the executable via a mat file. The results of the simulation (i.e what would normally be written to the MATLAB Workspace) gets written to a mat file created by the executable.
    2. Within you MATLAB code: replace all Simulink functionality with a call (typically using the system function, as shown in the linked example) to the executable created in step 1. Prior to this call you'll need to create a mat file with all your parameters in it; and after the call you'll want to read results from the mat file created by the executable.

    It's not a trivial process, but is do-able.

    这篇关于MATLAB deploytool simulink未定义的函数'load_system'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆