简化表达式“x”的正确方法是什么?加“x”在 MATLAB 中?
我有一个非常简单的问题:我试图简化表达式 x + x
以获得 MATLAB 中的答案 2x
但我很难弄清楚正确的格式,我不知道在文档文件中搜索什么来寻找答案。
I have a very simple question: I'm trying to simplify the expression x + x
to get the answer 2x
in MATLAB but I'm having a hard time figuring out the proper format and I don't know what to search in the documentation files for an answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑:
从下面的评论来看,您似乎需要符号工具箱。可以在此答案中找到一个基本示例。一旦将
x
设置为符号变量,x+x
应该为您提供2*x
。原答案:
你的问题目前来说不是很清楚。我将你的问题解释为以下含义:
在 MATLAB 中,需要明确说明算术运算。标量乘法的运算符是
*
,您可以将上面的内容写为2*x
。 这里是各种算术运算及其规则的文档 ;语法。在大多数情况下,如果您熟悉线性代数,您会发现 MATLAB 非常易于使用。如果我错了并且您的意思是其他,请编辑您的问题以澄清(和/或在此处留下评论),我将更新我的答案。
EDIT:
From the comments below, it looks like you need the symbolic toolbox. A basic example can be found in this answer. Once
x
is set to be a symbolic variable,x+x
should give you2*x
.Original answer:
Your question, as it stands, is not very clear. I'll interpret your question to mean the following:
In MATLAB, arithmetic operations need to be explicitly stated. The operator for scalar multiplication is
*
and you would write the above as2*x
. Here is the documentation for the various arithmetic operations, and their rules & syntaxes. For the most part, if you're familiar with linear algebra, you'll find MATLAB pretty easy to use.If I'm mistaken and you meant something else, please edit your question to clarify (and/or leave a comment here) and I'll update my answer.