在matlab R2011b中是否可以使用命令别名? [英] Is there a way to do command aliasing in matlab R2011b?

查看:78
本文介绍了在matlab R2011b中是否可以使用命令别名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Matlab相对较新. 我正在尝试为如下所示的命令创建别名.

I am relatively new at Matlab. I am trying to create an alias for a command that looks like the following.

run('full/path/to/some/script').

特别是,我希望能够写出与Bash相同的内容

In particular, I would like to be able to write something equivalent to Bash's

alias myAlias = run('full/path/to/some/script')

然后可以键入myAlias并获得与右侧相同的效果.

And then be able to type myAlias and get the same effect as the right hand side.

我在此处中查看了文档,但是我仍然得到了即使尝试在提示符下第一次键入syms时,也仍然尝试使用错误Undefined function or variable 'alias',所以我相信我没有正确导入工具箱,或者这不是R2011b的功能.

I have looked at the documentation here, but I still get the error Undefined function or variable 'alias' when I try to use it, even after I first type syms at the prompt, so I believe that either I am not importing the toolbox correctly or this is not a feature in R2011b.

另一个要求是,即使我调用clear,我也希望别名保持不变,这应该清除工作空间中的所有其他活动变量.

One additional requirement is that I would like the alias to stick even after I call clear, which should clear all the other active variables in the workspace.

推荐答案

例如:

f = @() run('foldername\scriptname')

然后只需编写f()即可执行scriptname. 在这里,我使用了一个匿名函数,您可以根据需要向其中添加更多内容.

then just writing f() will execute scriptname. Here I've used an anonymous function, you can add more content to it if needed.

这篇关于在matlab R2011b中是否可以使用命令别名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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