MATLAB: How to use fsolve to find constants after integration

fsolveintegration

I want my function to show me what the value of the constants c1 and c2 after i integrated them. I have to use the fsolve command, however i get the error message:
"FSOLVE requires all values returned by functions to be of data type double"
i'm fairly new to matlab so any help is greatly appriciated 🙂
function myfuntest
clc;
syms x; syms c1; syms c2;
expr = 2*x;
F1 = (int(expr)+c1);
F2 = (int(F1)+c2);
clear x;
x = 1;
F1 = eval(F1); F2 = eval(F2);
clear c1; clear c2;
fhandle = @ftn;
X0 = [1; 1];
X = fsolve(fhandle,X0);
disp(X)
x = 1; c1 = X(1); c2 = X(2);
function c = ftn(X)
x = 1;
c1 = X(1);
c2 = X(2);
c = [F1; F2]
end
end

Best Answer

syms x; syms c1; syms c2;
expr = 2*x;
F1 = (int(expr)+c1);
F2 = (int(F1)+c2);
fhandle = matlabFunction(subs([F1,F2],'x',1))
fhandle = function_handle with value:
@(c1,c2)[c1+1.0,c1+c2+1.0./3.0]
fhandle=@(C)fhandle(C(1),C(2));
C= fsolve( fhandle, [1;1])
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
C = 2×1
-1.0000 0.6667