MATLAB Answers

converting sym to double

112 views (last 30 days)
i have been working on this code
syms k
K = zeros(8);
K(1,1) = 0.7499*k
MATLAB shows the error "unable to convert expression into double array"
Also in general How do I create a matrix with symbolic expressions as element values for any given matrix.

  0 Comments

Sign in to comment.

Accepted Answer

Sriram Tadavarty
Sriram Tadavarty on 19 Mar 2020
Hi Parth,
The way the syms is used here is the issue. See the link, which provides examples to get started.
Do not define the K with double variables and that should help. Instead directly create the matrix with those many symbolic variables.
Hope this helps.
Regards,
Sriram

  0 Comments

Sign in to comment.

More Answers (1)

Steven Lord
Steven Lord on 19 Mar 2020
Make K a sym array from the start. Then MATLAB doesn't need to convert the symbolic expression 0.7499*k when assigning into an element of K.
K = sym(zeros(8));

  1 Comment

Parth Jain
Parth Jain on 19 Mar 2020
yep this worked!!

Sign in to comment.

Sign in to answer this question.


Translated by