How to assign a symbolic matrix to another new matrix?
12 views (last 30 days)
Show older comments
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 Comments
Answers (1)
John D'Errico
on 13 Sep 2022
Edited: John D'Errico
on 13 Sep 2022
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 Comments
John D'Errico
on 13 Sep 2022
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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!