フィルターのクリア

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

2 ビュー (過去 30 日間)
Shreshtha Chaturvedi
Shreshtha Chaturvedi 2022 年 7 月 9 日
編集済み: Torsten 2022 年 7 月 9 日
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 Center および File ExchangeLogical についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by