The following error occurred converting from sym to double: DOUBLE cannot convert the input expression into a double array.

2 views (last 30 days)
syms a b c d e f g h
I am trying to write a code for linprog, so i defined this constant variables
% Lower bounds
lb =(zeros(6,1));
lb(1,2,5,6) = [e,g,a,c];
Then I got the following error from matlab:
The following error occurred converting from sym to double:
DOUBLE cannot convert the input expression into a double array.
please help.

Accepted Answer

Star Strider
Star Strider on 25 Mar 2019
To define a vector of subscripts to ‘lb’, use square brackets, just as you woukld with any other array:
syms a b c d e f g h
lb([1,2,5,6]) = [e,g,a,c];
producing:
lb =
[ e, g, 0, 0, a, c]

More Answers (0)

Community Treasure Hunt

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

Start Hunting!