hello, i have a system of n equations which i need to differentiate, so the variables must be symbolic variables, and i stored those equations in an array, my problem is that i want to solve the system using the fsolve but i am not able to convert my symbolic variables to double, so let my code be like that:
function dif = mydifffunction2 (~)n=input('n=');h=3;dif=sym(zeros(1,n));F=0;x=sym(zeros(1,n));for k=1:n x(k) = sym(sprintf('x%d',k));endfor i=1:n D= 0.5;% V=0;
% b=0;
for j=1:n if (mod(j,2)==0) D = D + cos(h*x(j)); else D = D - cos(h*x(j)); end end D=(2*sqrt(2)/(pi*h))*abs(D); F = F + 1/h*(D^2) h=h+2;endfor j=1:n dif(j)=diff(F,x(j),1);end
how can i convert each of these variables to double??? Thanks in advance.
Best Answer