Search code examples
matlabmupad

How to convert DOM::MATRIX to Function


A simple example of what I am doing is as follows:

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);

The error is:

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

so, I need to convert types from Dom::Matrix to Function. I have tried:

coerce(X,DOM_EXPR);

I know that simply, this works:

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

Is there a way to convert these types?


Solution

  • While the variable X itself is a DOM::Matrix(), the single element it contains is an arithmetical expression, so you need to pass the element itself to the plot function:

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