syms m n
A=[1,2,3,4,5,6,7];
B=[1,3,5,7,8,9,10];
P=[3,4,7];
A(P)=A(P)+m
B(P)=B(P)+n
错误代码提示
Unable to perform assignment because value of type 'sym' is not convertible to 'double'.
原因:
错误使用 symengine
Unable to convert expression containing symbolic variables into double array. Apply 'subs' function
first to substitute values for variables.
你好,如果要用符号表达建议都用符号
syms m n
A=sym([1,2,3,4,5,6,7]);
B=sym([1,3,5,7,8,9,10]);
P=sym([3,4,7]);
A(P)=A(P)+m
B(P)=B(P)+n
结果:
A =
[ 1, 2, m + 3, m + 4, 5, 6, m + 7]
B =
[ 1, 3, n + 5, n + 7, 8, 9, n + 10]