assigning leads to empty value
조회 수: 8 (최근 30일)
이전 댓글 표시
I construct some functions depending on w. But if I assign some value w (of type double) with nonnegativ y df_v returns just a empty value [ ].
func = parabolicCylinderD(x(w),y));
df = diff(func)
....
f_v = func(w);
df_v = df(w);
댓글 수: 2
chicken vector
2023년 5월 15일
You need to share the code of your function otherwise it's impossible for us to help you.
답변 (2개)
chicken vector
2023년 5월 15일
편집: chicken vector
2023년 5월 15일
The function fe containts a function called whittakerM which is not explicit and it can't be derived.
The problem originates from these two expression included in df:
diff(whittakerM(E.^2./2.0-M.^2./2.0+1.0./4.0,-1.0./4.0,k),E)
diff(whittakerM(E.^2./2.0-M.^2./2.0+1.0./4.0,1.0./4.0,k),E)
When you substitute values for E, M and k, the diff operation becomes numerical but is performed on only one double thus returning an empty value:
diff([1 2])
diff(1)
In general you would have two options: either you derive a close form of whittakerM so you can perform analytical derivation, or you opt for numerical methods.
In your case you can't do neither of these because, as you can see from the expresions above, your variable E is also the degree of the derivative that has to be computed [diff(f,n) computes the n-th derivative].
This means that your function is defined for non-negative integers only and it is not continuous, thus the derivative has no mathematical meaning.
Walter Roberson
2023년 5월 15일
The basic problem is that there are two important functions named diff.
The primary diff() function calculates x(2:end) - x(1:end-1) which is numeric differences.
In the special case that the first parameter to diff() is symbolic or symfun then you instead get symbolic derivative (calculus).
Your code is working purely numerically, so diff() is numeric differences.
Note that numeric diff() does not do a numeric estimate of derivative: you need gradient() for that.
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear Algebra에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
