Problem with fsolve function in my equation systems

1 view (last 30 days)
I'm a beginner in Matlab and I try to calculate this system:
equagenral1.m:
function F = equageneral1(x,lambda,mu,B,c,b,a,n,e,z,R,y)
F=[
x(3)+(lambda*(mu*x(2)-x(1)-B)+c)/(b+lambda)
x(2)+((a*n*(e+z*((1/((2*pi)^(1/2)))*y)))+lambda*mu*(x(3)-x(1)-B)-c)/(a+lambda*(mu^2))
-a*z*((1/((2*pi)^2))*(exp((-(-1.2-(R+x(1)))^2)/2)))*(x(2)+n*(e+z*((1/((2*pi)^(1/2)))*y)))+lambda*(mu*x(2)+x(3)-x(1)-B)+z*((1/((2*pi)^2))*(exp((-(-1.2-(R+x(1)))^2)/2)))
];
This is how I try to do this:
calcul.m:
R=16.09;
syms x
y=int(exp(((-1.2-(R+x(1))).^2)/2),0,+inf);
lambda = 1.7723;
mu = 0.50;
B = 21.6;
c = 1;
b = 9.0759;
a = 0.9657;
n = 1;
e = 0;
z = 0;
R=16.09;
Rss=0;
options=optimset('MaxFunEvals',1000);
[ex,fval]=fsolve(@(x)equageneral1(x,lambda,mu,B,c,b,a,n,e,z,R,y),[0 0 0],options);
But the answer tell me that FSOLVE requires all values returned by user functions to be of data type double.
How can I fix that?
Thank you!
Paul-André
  3 Comments
Paulandre
Paulandre on 21 Nov 2013
Yes x(1) inside of y refer to the value of the vector x inside of equageneral1.
y=int(exp(((t-(R+x(1))).^2)/2)dt,0,+inf), where t=-1.2
If I put this equation in function form instead of as a variable, an other error appear.
How can I insert the int in equagenral1 without error?
Thank for helping me
Pa
Paulandre
Paulandre on 21 Nov 2013
You can also try like this:
equageneral1.m:
function F = equageneral1(y,lambda,mu,B,c,b,a,n,e,z,R,M) F=[
y(3)+(lambda*(mu*y(2)-y(1)-B)+c)/(b+lambda)
y(2)+((a*n*(e+z*((1/((2*pi)^(1/2)))*M)))+lambda*mu*(y(3)-y(1)-B)-c)/(a+lambda*(mu^2))
-a*z*((1/((2*pi)^2))*(exp((-(-1.2-(R+y(1)))^2)/2)))*(y(2)+n*(e+z*((1/((2*pi)^(1/2)))*M)))+lambda*(mu*y(2)+y(3)-y(1)-B)+z*((1/((2*pi)^2))*(exp((-(-1.2-(R+y(1)))^2)/2)))
];
and calcul:
calcul.m:
R=16.09;
syms y
x=-1.2;
M=int(exp(((x-(R+y(1))).^2)/2),0,+inf);
lambda = 1.7723;
mu = 0.50;
B = 21.6;
c = 1;
b = 9.0759;
a = 0.9657;
n = 1;
e = 0;
z = 0;
R=16.09;
Now i think that int() the variable of the integration is now x. But I have the same error.

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!