Convert syms matrix to double
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How to convert the matrix with syms in double.
The use of double print error.
0 commentaires
Réponses (1)
Star Strider
le 21 Nov 2022
That is not possible. The reason is that the matrix contains symbolic variables. They have to be assigned numeric values to use the double function.
syms a1 a2 a3
c = [0 0 0 0 0; 0 a1 0 0 0; 0 0 a2 0 0; 0 0 0 0 0; 0 0 0 0 a3];
cfcn = matlabFunction(c)
c = cfcn(21,42,84)
That ‘c’ matrix you can now use in other calculations outside the Symbolic Math Toolbox.
.
5 commentaires
Star Strider
le 21 Nov 2022
Another option is to use the diag function. You have to determine what elements of the vector are non-zero, and either set the length using the zeros function and then fill the appropriate positions, or always have the (n,n) entry as the last element in the vector, where the dimensions of the matrix are (n,n).
Example —
c = diag([0 21 42 0 84])
It might be possible to create that as a function as well, specifying the positions and their values as arguments, depending on what you want. (I have no idea that that is just now.)
.
Voir également
Catégories
En savoir plus sur Conversion Between Symbolic and Numeric dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!