필터 지우기
필터 지우기

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