作业帮 > 综合 > 作业

MATLAB符号表达式赋值问题!

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/08 07:17:36
MATLAB符号表达式赋值问题!
syms x;
A=zeros(9,9);B=[x^5,x^3,x;3*x^2,4,7*x^4;5,7,1];
A(1:3,1:3)=B;可以实现,但
A(1:3,1:3)=A(1:3,1:3)+B;就不行,错误报告如下:
The following error occurred converting from sym to double:
Error using ==> mupadmex
Error in MuPAD command:DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable,use the VPA function instead.
我这里matlab试的时候,A(1:3,1:3)=A(1:3,1:3)+B;也不能实现.
原因是A是double类型的,而B是sym类型的.
A没能够实现强制转换.
可以这样:
A1= A(1:3,1:3);
A1=B;
A1=A1+B;
再问: 我是想把A的分块矩阵拿来运算,结果再返回到这个分块矩阵中,你这样只是新建了一个符号型矩阵而已,不是我想要实现的。。。。 错误报告里说,用VPA,这个我不会,你会不?
再答: VPA不太了解。 不过,你可以试试: A=[A1,zeros(3,6);zeros(6,9)]; 这样A是不是你想要的呢?
再问: 我已经研究出来了 A=VPA(zeros(9,9));解决了。。。