How do I multiply a matrix and a column vector of variables ?

2 次查看(过去 30 天)
I have a matrix 'F' (3 * 20 double) and a cell-type 'ans' (20*1) consisting of variables of the form (1,x,y,z,xy,yx,...). The 'ans' is an output of a function called Poly_List that gives us a list of polynomials. I wanted to multiply F and ans to get a system of equations and use that to get the function
f = @(t,y) F * ans
which I will later use to solve ODEs. This gives me the error
Operator '*' is not supported for operands of type 'cell'.
I thought converting it into type double will help. But when I run
var = str2double(ans)
then var is simply consisting of NaN instead of the variables. Can someone please help?

采纳的回答

Torsten
Torsten 2022-7-9
编辑:Torsten 2022-7-9
Try a combination of str2sym and cell2sym (I don't know the class of "ans" from your description) to convert ans to a symbolic column vector "Ans". Then use
f = matlabFunction(F * Ans)
to convert the matrix-vector-product to a normal function handle.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by