从Matlab函数运行Simulink(Run Simulink from Matlab function)
我正在使用FastRestart运行Simulink,因为我需要多次启动和停止模拟更改参数。 当我从主脚本运行Simulink时,没有问题。 但是,只要我使脚本成为一个函数,以便我可以为不同的输入数据运行它,我就会得到一个与Simulink明显相关的错误,而不是在函数中看到Matlab工作区。
更确切地说,假设
sfile
是我的Simulink文件,然后在Matlab中初始化我需要的所有变量之后运行以下行:load_system(sfile); set_param(sfile,'FastRestart','on'); set_param(sfile,'SaveFinalState','on'); set_param(sfile,'SaveCompleteFinalSimState','on'); set_param(sfile,'SimulationCommand','update');
在最后一行,我得到了Simulink无法识别
mdl.tStep
(这是时间步长)的错误,因为mdl
不是公认的结构。 事实上,如果我从主脚本运行Simulink,一切都很好。现在,在过去,我会用
options = simset('SrcWorkspace','current');
但是,我认识的专家建议我反对
simset
(因为它可能会在将来被弃用),并鼓励我使用set_param
。 我已经在线查找了set_param的选项,但是我找不到Matlab工作区的设置。任何帮助将不胜感激。 先谢谢你!
I am running Simulink using FastRestart, as I need to start and stop the simulation multiple times changing parameters. When I run Simulink from the main script, there are no problems. However, as soon as I make the script a function so that I can run it for different input data, I get an error that is clearly related to Simulink not seeing the Matlab workspace within the function.
To be more precise, say
sfile
is my Simulink file, then I run the following lines AFTER having initialized all variables I need in structures in Matlab:load_system(sfile); set_param(sfile,'FastRestart','on'); set_param(sfile,'SaveFinalState','on'); set_param(sfile,'SaveCompleteFinalSimState','on'); set_param(sfile,'SimulationCommand','update');
At the last line, I get the error that Simulink does not recognize
mdl.tStep
(which is the time step), asmdl
is not a recognized structure. In fact, it is and if I run Simulink from the main script everything is fine.Now, in the past, I would have used
options = simset('SrcWorkspace','current');
However, an expert I know has advised me against
simset
(as it may get deprecated in the future) and encouraged me to useset_param
instead. I have looked up the options for set_param on-line, but I could not find the setting for the Matlab workspace.Any help would be greatly appreciated. Thank you in advance!
原文:https://stackoverflow.com/questions/42697878
最满意答案
在试图找出忽略某些东西的原因时,使用
git check-ignore
命令通常很有用:$ git check-ignore --verbose some/file.txt .gitignore:1:some some/file.txt
输出可以这样解释:
如果指定了
--verbose
,则输出是以下形式的一系列行:<source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname>
<pathname>
是要查询的文件的路径,<pattern>
是匹配模式,<source>
是模式的源文件,<linenum>
是该源中模式的行号。 如果图案包含!
前缀或/
后缀,它将保留在输出中。 当引用core.excludesfile
文件配置的文件时,<source>
将是绝对路径,或者在引用.git/info/exclude
或每个目录的排除文件时,相对于存储库根目录。When trying to figure out why something is ignored, it is often useful to use the
git check-ignore
command:$ git check-ignore --verbose some/file.txt .gitignore:1:some some/file.txt
The output can be interpreted like so:
If
--verbose
is specified, the output is a series of lines of the form:<source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname>
<pathname>
is the path of a file being queried,<pattern>
is the matching pattern,<source>
is the pattern’s source file, and<linenum>
is the line number of the pattern within that source. If the pattern contained a!
prefix or/
suffix, it will be preserved in the output.<source>
will be an absolute path when referring to the file configured bycore.excludesfile
, or relative to the repository root when referring to.git/info/exclude
or a per-directory exclude file.
相关问答
更多-
在试图找出忽略某些东西的原因时,使用git check-ignore命令通常很有用: $ git check-ignore --verbose some/file.txt .gitignore:1:some some/file.txt 输出可以这样解释: 如果指定了--verbose ,则输出是以下形式的一系列行:
-
看了很多,我发现问题是通过访问GitHub并查看.gitignore文件,它在node_modules/的开头有一个非常奇怪的字符,但由于某种原因它没有出现在Sublime Text上。 现在它正确地忽略了该文件夹。 After looking a lot around I found the issue by going to GitHub and looking at the .gitignore file, it was having a really weird character at the b ...
-
这是一个子模块。 要删除它,请执行以下操作: 从.gitmodules文件中删除相关行 从.git / config中删除相关部分 运行git rm --cached path_to_submodule(没有尾部斜杠) 提交并删除现在未跟踪的子模块文件。 It is a submodule. to remove it do the following: Delete relevant line from the .gitmodules file Delete relevant section from .g ...
-
该图标表示:嵌套的git存储库。 含义:当你执行git add * ,你添加了嵌套git repo angular2-webpack-starter的顶层文件夹,将其记录为gitlink ( 父repo中的特殊条目 ,作为表示嵌套repo树的SHA1) 如果你真的想要包含angular2-webpack-starter的内容,你需要在``angular2-webpack-starter / .git`子文件夹中删除,并删除gitlink,然后重新添加文件夹: git rm --cached angular2 ...
-
我遇到了同样的问题,即使我已经使用这个遥控器很长一段时间了,我最近没有改变任何东西。 我认为它与Github最近的制动和减速有关,事实上,他们已经在他们的Twitter账户上证实了这一点: https : //twitter.com/githubstatus/status/717464295454470145 我们的系统正在通过队列积压工作。 与此同时,新的推送可能需要一些时间才能显示在http://GitHub.com上 。 希望提交将很快出现在Github上:) I'm experiencing the ...
-
如何删除本地删除的github仓库中的文件夹?(How to remove a folder within a github repo that was deleted locally?)[2022-06-18]
只需添加目录中的所有内容,并将github与您的文件夹同步。 git add * git commit -m "removed a folder" git push origin master Just add everything in that is in your directory right now and have github sync with your folder. git add * git commit -m "removed a folder" git push origin ... -
它( bsg-services )是一个子模块 。 (参见“ 这个灰色git图标是什么? ”) 你需要: 通过首先进入该文件夹来添加/提交(并从该子仓库推送), ( bsg-services内的git状态会告诉你更多) 然后回到父回购(你在哪里),添加,提交和推送。 您将在bsg-services内完成的提交将修改父repo索引中的gitlink条目 。 所以你需要两个推动: 一个从子模块repo到它的上游repo(一个git remote -v应该告诉你) 一个来自父repo,以记录新的gitlink S ...
-
首先检查你的状态和分支: git status git branch 如果您没有看到以* 开头的分支 ,则表示您正在分离的HEAD分支中工作 。 如果是这种情况,只需将主分支重置为当前HEAD并再次推送: git checkout -B master @ git push OP jebmarcus 在评论中确认在主分支上,并且状态清晰: 当我今天早上刷新回购时,一切都恢复了 这一定是GitHub方面的一个小故障。 GitHub上存在连接问题(8月3日发生了“轻微服务中断” - GitHub状态消息 )。 ...
-
您已将更改提交到存储库的本地克隆。 如果你想在GitHub上看到那个提交,你需要首先git push它git push到那里。 You committed that change to the local clone of the repository. If you want to see that commit on GitHub, you'll need to git push it there first.
-
将git连接到Github帐户(connect git to Github account)[2022-07-12]
在github上创建一个新的存储库(参见Github主页上的“New repository”按钮) 将此存储库添加为远程: git remote add origin url/provided/by/github 推送到此存储库: git push origin master Create a new repository on github (cf the "New repository" button on Github main page) Add this repository as a remot ...