How to assign a symbolic matrix to another new matrix?
12 次查看(过去 30 天)
显示 更早的评论
clc
clear
syms t
ddq=zeros(4,11);%can not be deleted
ddq(1:4, 1)=[sin(25*t); 55*sin(25*t);65*sin(25*t);0]
0 个评论
回答(1 个)
John D'Errico
2022-9-13
编辑:John D'Errico
2022-9-13
You are NOT assigning a symbolic matrix to another "new" matrix, but you are instead trying to stuff symbolic elements into an existing double precision array, replacing only some of the existing elements. Do you see the difference?
A double precision array can contain only double precision numbers.
What exactly you are trying to do, and why you are trying to do this, I cannot know. Why it is that you think the array ddq cannot be overwritten or deleted, I do not know.
2 个评论
John D'Errico
2022-9-13
Are you asking for a way to do what cannot be done? I'd then suggest magic.
Seriously, if the matrix MUST remain as it is, as a double precision matrix, then you CANNOT insert symbolic elements.
If you are willing to modify the matrix, then you can recast it as a symbolic matrix. Then you can then insert symbolic elements. For example:
M = magic(3)
A matrix of doubles.
First, recast it as symbolic.
M = sym(M)
syms t
M(2,2) = t + 2
At this point however, the entire matrix is symbolic. It is no longer the double precision matrix you started with, and some computations may become exceedingly CPU intensive, or they may become completely impossible, if some piece of code you use does not allow symbolic matrices.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!