converting sym to double

조회 수: 4 (최근 30일)
Parth Jain
Parth Jain 2020년 3월 19일
댓글: Parth Jain 2020년 3월 19일
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.

채택된 답변

Sriram Tadavarty
Sriram Tadavarty 2020년 3월 19일
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

추가 답변 (1개)

Steven Lord
Steven Lord 2020년 3월 19일
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
Parth Jain
Parth Jain 2020년 3월 19일
yep this worked!!

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by