Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
I am complete new , and do not know how to modify this~
조회 수: 3 (최근 30일)
이전 댓글 표시
syms x
T=1;
lamda=0.5;
gamma=1;
t=0.1;
theta=0.1;
U=lamda/(0.5*theta^2+lamda);
V0(x)=-U.*exp(-gamma.*x)+(1-U).*exp(-(0.5.*theta.^2+lamda).*(T-t)).*exp(-gamma.*x);
R=-diff(V0)./diff(V0,2)
Error:
The following error occurred converting from sym to double:
Error using mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
댓글 수: 0
답변 (1개)
Walter Roberson
2015년 11월 14일
편집: Walter Roberson
2015년 11월 14일
You have
V0(x)=-U.*exp(-gamma.*x)+(1-U).*exp(-(0.5.*theta.^2+lamda).*(T-t)).*exp(-gamma.*x);
which attempts to index something at the symbolic variable x. Your MATLAB is attempting to convert that symbolic x into a numeric value to use as an index in to V0.
You need to add
syms V0(x)
before you have that statement so that MATLAB knows you are defining a symbolic function.
If MATLAB complains about
syms V0(x)
being a syntax error then you have a version of MATLAB that is too old to support that. If that happens then instead use
V0 = -U.*exp(-gamma.*x)+(1-U).*exp(-(0.5.*theta.^2+lamda).*(T-t)).*exp(-gamma.*x);
R = -diff(V0,x) ./ diff(V0,x,2);
댓글 수: 1
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!