I have faced with this error namely: FSOLVE requires all values returned by functions to be of data type double. Apparently, my mistake concerned to fsolve function.
I wonder if you tackle this problem. I write my code as follows:
clc clear all close all syms t y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 f1(t)=input(' input function ( 0<t<1 ) : f1(t)= ' ); f2(t)=input(' input function ( 0<t<1 ) : f2(t)= ' ); b1(t,y)=input(' input function ( y=y(t) ) : b1(t,y)= ' ); b2(t,y)=input(' input function ( y=y(t) ) : b2(t,y)= ' ); a=0; b=1; n1=10; %just an even number%
m=100; n=100; Z1=[ x1 x2 x3 x4 x5 ]; Z2=[ x6 x7 x8 x9 x10 ]; A=zeros(n1/2,n1/2); for i=1:(n1/2) for j=1:(n1/2) A(i,j)=int(t^i,0,1)*(2*i+3*j^2)/((1+i+j)^2); P(i,j)=(i^2-i*j+j^2)/((1+i*j)^2); end end A Pi=1;for j=1:m dt=(b-a)/n; dB1=sqrt(dt)*randn(1,n); B=cumsum(dB1); for k=1:(n1/2) Q1(k)=B(k*n/n1); Q2(k)=B((k+5)*n/n1); end Q1 Q2 F(t)=Z1*A(:,i)-b1(t,f1(t)+Z1*P*A(:,i))+Z2*Q1'-b2(t,f2(t)+Z2*P*Q2'); for l=1:n1 Eqs(l)=F(2*l-1)/(2*n1); x=[x1,x2,x3,x4,x5,x6,x7,x8,x9,x10]; end f=@(x)[Eqs(1) , Eqs(2) , Eqs(3) , Eqs(4) , Eqs(5) , Eqs(6) , Eqs(7) , Eqs(8) , Eqs(9) , Eqs(10)]; x0=[0 0 0 0 0 0 0 0 0 0]; w(i,:)=fsolve(f,x0) i=i+1; end MW=mean(w);SW=std(w);L=MW-1.96/sqrt(m)*SWU=MW+1.96/sqrt(m)*SW
————————————————
Please input the functions as you wish.
For example: f1(t)=f2(t)=t , b1(y,t)=b2(y,t)=y+t ;
————————————————-
Thank you in advance.
Best Answer