【问题标题】:How to convert DOM::MATRIX to Function如何将 DOM::MATRIX 转换为函数
【发布时间】:2016-02-26 16:56:12
【问题描述】:

我正在做的一个简单的例子如下:

s := t*0.2:
b := matrix([0.5,0.6,0.1]):
f := matrix([sin(s),cos(s),s]):
X := transpose(b)*(f);
plotfunc2d(X,t=-2*PI..2*PI);

错误是:

Error: Expecting an arithmetical expression or a function. Got a 'Dom::Matrix()' for attribute 'Function' in the 'Function2d' object.

所以,我需要将类型从 Dom::Matrix 转换为 Function。我试过了:

coerce(X,DOM_EXPR);

我知道这很简单:

s := t*0.2:
x := 0.5*sin(s)+0.6*cos(s)+0.1*s;
plotfunc2d(x,t=-2*PI..2*PI);

有没有办法转换这些类型?

【问题讨论】:

    标签: matlab mupad


    【解决方案1】:

    虽然变量X 本身是一个DOM::Matrix(),但它包含的单个元素是一个算术表达式,因此您需要将元素本身传递给绘图函数:

    plotfunc2d(X[1],t=-2*PI..2*PI);
    

    【讨论】:

    • 完美!没想到。
    猜你喜欢
    • 2015-07-23
    • 1970-01-01
    • 1970-01-01
    • 2011-06-03
    • 1970-01-01
    • 2018-04-04
    • 1970-01-01
    • 2021-02-26
    • 2022-12-03
    相关资源
    最近更新 更多