Erro in calling function in fsolve that has conditional operators
조회 수: 2 (최근 30일)
이전 댓글 표시
Here is my full code:
s1=4;
s2=1.2;
r=0.3;
t1=2.52;
tu=37; %limit for qfunc
v1=sqrt(1-r^2);
v2=r/v1;
v3=exp(-s2^2/2);
c1=t1/v1;
c2=(s1-r*s2)/v1;
x2d=(c1+tu)/v2;
x2n=x2d-c2/v2;
F1=ferror(x2d,x2n)
Error=fsolve(@(x2) F1,0)
function F1=ferror(x2d,x2n,x2)
%case 1 x2<x2n
if x2 < x2n
F1= v3.*exp(x2.*s2).*qfunc(-c1+v2.*x2)/qfunc(-c1+c2+x2.*v2);
% case 2 x2n<x2<x2d
else if x2n <= x2 & x2 <= x2d
F1 = -(v3.*exp(x2.*s2-(-c1+v2.*x2)^2/2))/(qfunc((-c1+c2+x2.*v2))*sqrt(2*pi)*(-c1+v2.*x2));
%case 3 x2>x2d
%
else
F1 = v3.*((-c1+c2+x2.*v2)/(-c1+v2.*x2)).*exp(-(-c1+v2.*x2)^2/2+(-c1+c2+x2.*v2)^2/2+x2.*s2);
end
end
end
If I run this it says undefined variable x2
please help.
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!