The following error occurred converting from sym to double: Unable to convert expression into double array.

2 views (last 30 days)
The following error occurred converting from sym to double:
Unable to convert expression into double array. main purpose is to create a matrix which has unknowns x and y which will be calculated later. So I already created ONM matrix( size 4x1)
After that I tried to assign the elements of ONM matrix to 3rd column of another matrix that is called NM (size 4x1). But the error occured.
How can I fix it?
Thanks for your help
syms x y real
ONM1=[0 x y 0]
ONM=ONM1'
NM(:,3)=(ONM(:,2))

Accepted Answer

Walter Roberson
Walter Roberson on 22 Sep 2021
When you created NM, you created it as a numeric array. You cannot "upgrade" a numeric array to be symbolic by assigning symbolic elements in the middle of it.
Before doing that last assignment, do
NM = sym(NM);
or arrange for NM to be constructed as sym when it is created.

More Answers (0)

Tags

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!