Defining a symbolic function in which one of the arguments is used to look up an entry of a vector, which is then used in the function.
조회 수: 2 (최근 30일)
이전 댓글 표시
I have defined several numbers and a vector as follows:
d1=-0.3;d2=0.4;
dv=[d1 d2];
I now attempt to define a function in which one of the arguments of the function is used to look up an entry of the vector dv; and the selected entry of the vector is then used in the function. I have defined this function as follows:
syms y z
THETA(y, z) = dv(y) + z
I then want to use the function in a for loop (:
for j=1:MB;
Nzero(j, a)=sqrt((1/conj(a) - dv(j))*(THETA(l, a) - dv(j))/((a - dv(j))*(THETA(l, 1/conj(a)) - dv(j))));
end;
The issue that I am having is that MATLAB halts at
THETA(y, z) = dv(y) + z
Have I defined this function in an appropriate way for my use? In particular, I think the problem is with the use of the object dv(y) in this function. Is there a better way to code for one of the function's arguments to be used to look up an entry of a vector, which is subsequently used in the function?
댓글 수: 0
채택된 답변
Star Strider
2016년 7월 20일
If your question is about your ‘THETA’ function, it would be best for numerical results (not symbolic) to use an anonymous function:
THETA = @(y, z) dv(y) + z;
I cannot run your code, but that form of the function should do what you want.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Number Theory에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!