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?
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!